如何让表单提交剪贴板的内容,请举个例
我事先复制了一个网址,我想在网页中实现提交剪贴板中的网址
我想到了先把网址从剪贴板中读取,赋值到一个字符串中,然后在表单中调用这个字符串.但不知道代码怎么写
请高手帮帮忙,把代码贴出来.让我有参考 谢谢!!!!!!!!!!
------解决方案--------------------function copyToClipBoard(){
var clipBoardContent = 'http://csdn.net ';
document.getElementById( "UserName ").value=clipBoardContent;
window.clipboardData.setData( "Text ",clipBoardContent);
alert( "复制成功 ");
}
<form name=form1 > <input type=text name=UserName id=UserName> </form>
试一下
------解决方案--------------------大致就下面这些代码,自己试一下吧
<%@ Page %>
<script language= "c# " runat= "server ">
void btnClick(object o , EventArges e){
string url = string.Empty;
if(null != Request.From[hd.ClientID]){
url = Request.From[hd.ClientID];
//now you get the client data on server side
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " lang= "gb2312 ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<meta http-equiv= "Content-Language " content= "zh-cn " />
<meta content= "all " name= "robots " />
<meta name= "Author " content= "huobazi@aspxboy.com ,サ銧ミラモ " />
<meta name= "Copyright " content= "www.AspxBoy.Com,ラヤモノー貶ィ,ネホメ籏ェヤリ. " />
<meta name= "Description " content= "www.AspxBoy.Com " />
<meta name= "Keywords " content= "www.AspxBoy.Com,サ銧ミラモ,huobazi " />
<title> New New Document </title>
<script language= "javascript " type= "text/javascript ">
function a()
{
var url = "http://www.aspxboy.com "// default url
if(window.clipboardData.getData( "Text ").length > 0){
url = window.clipboardData.getData( "Text ");
}
document.getElementById( ' <%= hd.ClientID %> ').value = url
}
</script>
</head>
<body>
<form id= "frm " runat= "server ">
<input type= "hidden " id= "hd " runat= "server " />
<asp:button id= "btn " OnClick= "btnClick " OnClientClick= "a(); " runat= "server " Text= "Submit " />
</script>
</body>
</html>