首页  ·  知识 ·  云计算
ASP.NET设置/获取/清空用户的剪贴板
佚名  http://www.cnblogs.com/blodfox777/  综合  编辑:dezai  图片来源:网络
We can Set/Get/Clear users’ clipboard by the javascript window.clipboardData object, which only works in Internet Explorer, by the following

We can Set/Get/Clear users’ clipboard by the javascript window.clipboardData object, which only works in Internet Explorer, by the following code:
 
window.clipboardData.setData("text",value)
window.clipboardData.getData("text")
window.clipboardData.clearData("text")
 
If you need set a code-behind value to user’s clipboard, please pass it to javascript variable first, and then, set the value to clipboard. Or you can call the javascript from code-behind, just like the following code:


 

protected void Button1_Click(object sender, EventArgs e)
{
    string values = "hello world";
    ClientScript.RegisterStartupScript(this.GetType(), "copy", "window.clipboardData.setData('text','"+values+"')", true);
}

Thanks.


 

本文作者:佚名 来源:http://www.cnblogs.com/blodfox777/
CIO之家 www.ciozj.com 微信公众号:imciow
   
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读