View Full Version : Copying an image
wickford
10-05-2003, 05:05 PM
Hi,
Is there a way to copy an image onto the clipboard? I tried using ExecCommand but it seems it can only copy text.
Any ideas will be appreciated.
Willy Duitt
10-05-2003, 08:57 PM
If in its own window:
alt & PrtScrn
Paste in Paint or other Image Tool
shlagish
10-06-2003, 12:40 AM
But that will copy the whole screen...
wickford
10-06-2003, 03:45 PM
Sorry for my vague description. I meant is there a way to copy an image by clicking a link?
shlagish
10-07-2003, 02:46 AM
I've never hear of it...
You mean that a code?
<a href="#null" onClick="CopyImage()">
Your looking for something like that? (No that won't work, lol;))
nolachrymose
10-07-2003, 07:32 PM
Are you trying to copy the image to the clipboard so that you can move it elsewhere? If so, you can use something like this (IE-only):
//img is a reference to an <img> element
function copyImage(img) {
event.dataTransfer.setData("URL", img.src);
}
//sample function usage
function placeElement(container) {
var imgsrc = event.dataTransfer.getData("URL");
var newNode = document.createElement("img");
newNode.setAttribute("src", imgsrc);
container.appendChild(newNode);
}
Hope that helps!
Happy coding! :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.