Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes How to copy a image to clipboard in FIREFOX browser using javascript? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to copy a image to clipboard in FIREFOX browser using javascript?" Watch "How to copy a image to clipboard in FIREFOX browser using javascript?" New topic
Author

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

Nagendra Batchu
Ranch Hand

Joined: Jan 23, 2008
Posts: 32
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
Marshal

Joined: Mar 22, 2005
Posts: 41571
    
  54
No, nor is there in any other browser. JavaScript in general can't access the clipboard.

createControlRange is a non-standard, IE-only method.


Ping & DNS - my free Android networking tools app
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jan 23, 2008
Posts: 32
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jan 10, 2002
Posts: 61043
    
  66

"nagendra bvvs", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"nagendra",
Please check your private messages regarding an important administrative matter.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to copy a image to clipboard in FIREFOX browser using javascript?