Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to copy a image to clipboard in FIREFOX browser using javascript?

 
Nagendra Batchu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Could any one please help me in, how to copy a image to clipboard using javascript in FIREFOX browser?

This i could get in IE with the following code, but it dint work in FIREFOX.
function copyToClpBrd()
{

var div = document.getElementById('chartId');
div.contentEditable = 'true';
var controlRange;
if (document.body.createControlRange) {
controlRange = document.body.createControlRange();
controlRange.addElement(div);
controlRange.execCommand('Copy');
}
div.contentEditable = 'false';
}

Could any one please let me know is there any way to do this in firefox.


Thanks a lot in advance.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, nor is there in any other browser. JavaScript in general can't access the clipboard.

createControlRange is a non-standard, IE-only method.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you search Google for Firefox JavaScript copy clipboard you will see how to do it. Problem is security settings. most browsers have this disabled by default.


Eric
 
Nagendra Batchu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for quick reply.

Or else could i ask you that, is there any other approch to do this?I mean using java?
Usually what developers will do if this requirement arrives...!?


thanks.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is running on the server and has no connection to the client. You can try to worrk with an applet, but that also has issues with support on the browser.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nagendra bvvs", please check your private messages for an important administrative matter.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nagendra",
Please check your private messages regarding an important administrative matter.
-Ben
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic