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