新手学做网站要花钱么,vs网站开发如何发布,网址大全123下载安装,白酒网站建设我们常用到剪切板#xff0c;在网页操作中#xff0c;如#xff0c;csdn 的网站#xff0c;会有一个复制按钮#xff0c;点击后#xff0c;会在复制的内容下有一行内容,提示复制的内容来自csdn#xff0c;并且下面会带有相关的连接。 在网页中有个对象clipboardData在网页操作中如csdn 的网站会有一个复制按钮点击后会在复制的内容下有一行内容,提示复制的内容来自csdn并且下面会带有相关的连接。 在网页中有个对象clipboardData此对象就是剪切板它有三个函数可进行操作 1. getData(Text),表示从剪切板中获取信息即有返回值 2. setData(“Text”,val).表示把val的值写入剪切板中 3. clearData(Text) ,清空剪切板 JS中是区分大小写的另其中的参数Text是不能省略的。 以下是建立三个textarea分别为ara1,ara2,ara3,放置四个按钮分别为复制、粘贴、清空、带小尾巴复制。 点击复制时会把ara1复制到剪切板点击粘贴时会把复制的内容写到ara2中清空时会调用clearData函数再在ara2中粘贴你会发现显示为null. 带小尾巴按钮是把ara1中的内容并带个尾巴粘贴到ara3中。 html xmlnshttp://www.w3.org/1999/xhtml
head runatservertitle/titlescript typetext/javascriptfunction copy() {var svalue document.getElementById(ara1).value;alert(svalue);clipboardData.setData(Text, svalue);}function paste() {var svalue clipboardData.getData(Text);document.getElementById(ara2).value svalue;}function cleara() {clipboardData.clearData(Text);}function copywithtailtotextarea() {var svalue document.getElementById(ara1).value;svalue svalue 本复制的内容网址: location.href;alert(svalue);clipboardData.setData(Text,svalue);document.getElementById(ara3).value clipboardData.getData(Text);}/script
/head
bodyform idform1 runatserverdivtextarea idara1 rows10testtesttesttesttesttesttesttesttesttesttesttesttest/textareanbsp;nbsp;nbsp;nbsp;nbsp;nbsp;textarea idara2 rows10/textareabr /input typebutton value复制 οnclickcopy()/nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;input typebutton value粘贴 οnclickpaste()/input typebutton value清空粘贴板 οnclickcleara()/input typebutton value带小尾巴复制 οnclickcopywithtailtotextarea() /textarea idara3 rows30/textarea/div/form
/body
/html 转载于:https://www.cnblogs.com/yagzh2000/archive/2013/05/20/3088503.html