473,507 Members | 12,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help: Copy Image to Clipboard

Hi,

I've searched dozens of forums and websites to find a way to have
javascript copy an image I click on into the clipboard of windows. I
found a few examples but I couldn't get any of them to work either
getting object doesnt support this method or other errors I don't
understand. If anyone has any working code for this I'd be very
thankful for it.

And yes, I know this only works in IE and I'm assuming that the user
will be using windows.

Thanks,

Kris

Sep 8 '05 #1
2 18185
<kr**********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi,

I've searched dozens of forums and websites to find a way to have
javascript copy an image I click on into the clipboard of windows. I
found a few examples but I couldn't get any of them to work either
getting object doesnt support this method or other errors I don't
understand. If anyone has any working code for this I'd be very
thankful for it.

And yes, I know this only works in IE and I'm assuming that the user
will be using windows.


Well... just because they're using Windows doesn't mean they're using IE
(and just because they're using IE doesn't actually mean they're using
Windows). ;^)

But anyways...

I don't believe you can, via script, copy an image. The scriptable
clipboardData element in IE only supports text (and "url" which isn't
helpful to you either). It can't copy binary data.

Using the scriptable element like this:

if ( window.clipboardData ) {
window.clipboardData.setData("Text", "Text to copy.");
};

You could copy the URL to the image, the name of the image or any other
textual information you like about it - but not the actual image.

Jim Davis
Sep 8 '05 #2
Actually it is possible. I just found out using this code:

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

Just replace DivtoCopy with the div that contains whatever you want to
copy into the clipboard.

kris

Sep 9 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2559
by: Meikel | last post by:
I created a ClipboardUtils class which makes it easy to copy Strings or images to the clipboard. I don't claim that it's no way perfect, but has been useful in my applications so far. If you try...
0
2098
by: TC | last post by:
Hello, Here is what I'm trying to do: -- Make sure both MS Excel and MS Word are running -- Create an Excel chart -- Save the Excel file -- Copy the Excel chart onto the clipboard using Ctrl...
5
4017
by: TC | last post by:
Hello, Here is what I'm trying to do: -- Make sure both MS Excel and MS Word are running -- Create an Excel chart -- Save the Excel file -- Copy the Excel chart onto the clipboard using Ctrl...
4
32191
by: Risto Heinonen | last post by:
Hi. I have a web page that has images and text. I can carefully select one image and the on the right of the image and then copy & paste to Word. Is it possible to make javascript do the same:...
1
2132
by: andrew | last post by:
I have a MSchart object (COM Component) which I wish to insert as an image into a picture box so that I can print it out. 'I call the chart controls's EditCopy to pass data to the clipboard. ...
7
11600
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
2
2520
by: John | last post by:
The following 4 lines add a border to a bitmap and save it into clipboard, however it also add a border to the bitmap on the screen. I want to create a temp copy of the bitmap and add a border to...
0
2638
by: mhospodarsky | last post by:
Hi-- I am using VB.Net 2002 for this app. I am working with Tiff and jpeg images. I have a picturebox set up that I use to view the images. I have the picture box inside of a scrollable...
2
3308
by: crapycoder | last post by:
hi all, please help....!! i have added a kodak image edit control on my form. when i click get image button, "abc.img" will be displayed. i have a button named "copy to clipboard". when...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.