62,025
社区成员
发帖
与我相关
我的任务
分享
if (!Page.IsPostBack)
{
hidTest.Value = HttpContext.Current.Request.Url.AbsoluteUri.ToString();
}
<script language="javascript">
function DoCopy()
{
if(document.getElementById('hidTest').value!="")
{
alert('测试');
document.getElementById('hidTest').select();
textRange = document.getElementById('hidTest').createTextRange();
textRange.execCommand("Copy");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HiddenField ID="hidTest" runat="server" />
<input type="button" value="获得URL" name="btnUrl" onclick="DoCopy()" />
</div>
</form>
</body>
<script type="text/javascript">
function DoCopy()
{
if (document.form1.CopyTxt.value != "")
{
document.form1.CopyTxt.select();
textRange = document.form1.CopyTxt.createTextRange();
textRange.execCommand("Copy");
}
}
</script>
<input onclick="DoCopy()" type="button" value="复制到剪贴板" class="button"/>
<script>
function oCopy(obj){
obj.select();
js=obj.createTextRange();
js.execCommand("Copy")
}
</script>
<input type="text" value="点击复制!" onclick="oCopy(this)">