Copying text into the clipboard with JavaScript

Posted by Naidulaxmi under JavaScript on 3/30/2012 | Points: 10 | Views : 20676 | Status : [Member] | Replies : 7
Hi Friends,

I am working on a website project in that project i have to allow Copy to Clipboard with Javascript on Mozilla Firefox,chrome and IE .
So please tell me how to Copying text into the clipboard with JavaScript.

How will do this most urgent.


Thanks & Regards,

appalanaidu


Responses

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
use below line

function setToclipboard(valToSet)
if (window.clipboardData && clipboardData.setData) {
clipboardData.setData("Text", valToSet);
}

Thanks,
Rajni Shekhar

Naidulaxmi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naidulaxmi on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
hi ,

not understand,plz explain more.

thanks & Regards,

appalanaidu

Naidulaxmi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
I have posted javascript code here.
setToClipboard(valTosend) call this function and send values whatever you want to save in clipboard. this will save your data in clipboard try thi.

function setToclipboard(valToSet) {
if (window.clipboardData && clipboardData.setData) {
clipboardData.setData("Text", valToSet);
}
}




Thanks,
Rajni Shekhar

Naidulaxmi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naidulaxmi on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
hi,

it is not working,plz help me.


Thanks,

appalanaidu

Naidulaxmi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
It is working in IE, i have checked it. do onething.

<script language="javascript" src="JScript1.js">
if (window.clipboardData && clipboardData.setData) {
clipboardData.setData("Text", "appalanaidu");
</script>
in your default.aspx page. and run the page and just open a notepad in your system and press ctl+v there.

Thanks,
Rajni Shekhar

Naidulaxmi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naidulaxmi on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
hi,


i want to working all browsers like Mozilla Firefox,chrome and IE.

Thanks,

appalanaidu

Naidulaxmi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
check this site

http://blog.logiclabz.com/javascript/copy-to-clipboard-with-javascript-on-mozilla-firefox-and-ie.aspx

Thanks,
Rajni Shekhar

Naidulaxmi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response