Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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.
 
Rancher
Posts: 43016
76
  • 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.
 
author
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
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
 
Marshal
Posts: 67445
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nagendra bvvs", please check your private messages for an important administrative matter.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nagendra",
Please check your private messages regarding an important administrative matter.
-Ben
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic