473,786 Members | 2,574 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 18323
<kr**********@y ahoo.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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.clipboar dData ) {
window.clipboar dData.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.getEle mentById('Divto Copy');
div.contentEdit able = 'true';
var controlRange;
if (document.body. createControlRa nge) {
controlRange = document.body.c reateControlRan ge();
controlRange.ad dElement(div);
controlRange.ex ecCommand('Copy ');
}
div.contentEdit able = '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
2596
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 it out and have improvement suggestions, let me know. It can also copy a graphical image of any JComponent to the clipboard. I also wondered how I could copy text AND images to the clipboard at the same time (e.g. an image with some explanatory...
0
2128
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 + C -- Go to Word and look under Edit > Paste Special -- Note there is a source reference and an option to paste the chart as a
5
4079
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 + C -- Go to Word and look under Edit > Paste Special -- Note there is a source reference and an option to paste the chart as a
4
32289
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: select the same area (divided by <div> tag) and copy to clipboard? So far I succeeded to make the script to copy the area inside <div> but it was plain html-text.
1
2153
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. Dim Img As Image MyChart.EditCopy() 'I then declare an IDataObject
7
11640
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 is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
2
2536
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 it without affecting the bitmap on the screen. Any suggestions? Thanks ''''' Dim g As Graphics = Graphics.FromImage(MyPpic.Image) Dim pen As New Pen(Color.Gray) g.DrawRectangle(pen, 0, 0, MyPpic.Image.Width - 1,
0
2666
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 panel.There are two viewing preferences available: to view the image with scrollbars (the original image unsized), and to view the iamge without scrollbars (the image resized to fit within the panel's viewing range.) When I resize the image so that...
2
3331
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 i click it, i want the image in kodak image edit control to be copied to clipboard.
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7515
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4067
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 we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.