Wednesday, June 5, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  124] [ 5]  / answers: 1 / hits: 17060  / 8 Years ago, wed, march 9, 2016, 12:00:00

i wrote Javascript that copies the data from textbox to the clipboard:



TextBox:



<asp:TextBox ID=contNoTxtBox runat=server Width=182px style=height: 22px></asp:TextBox>


Javascript:



function CopyToClipBoard()
{
var text = document.getElementById('contNoTxtBox').innerHTML;
window.clipboardData.setData('Text', text);
}


and i call it in HTML button the following way:



<input id=CopyButton type=button value=Copy onclick=CopyToClipBoard() /><br />


However i get the following error:




Uncaught TypeError: Cannot read property 'setData' of undefined




Why am i getting this type pf error?


More From » c#

 Answers
39

Referring to http://help.dottoro.com/ljctuhrg.php your




window.clipboardData.setData('Text', text);




is compatible with InternetExplorer only.
There are alternative ways to implement this using Chrome etc. shown in their examples.


[#63004] Sunday, March 6, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
savanar

Total Points: 237
Total Questions: 105
Total Answers: 99

Location: Wales
Member since Mon, May 17, 2021
3 Years ago
;