473,706 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JS to Clipboard

I'm new to JS.

I have some scripts that include a variable that I'd like to have js
copy to the Window's Clipboard. Is there a way to do this?

FWIW, I have the big O'Reilly book on JS but don't see what I want in
there (so far).

-
JohnW-Mpls
Jul 15 '07 #1
6 4298
JohnW-Mpls wrote:
I have some scripts that include a variable that I'd like to have js
copy to the Window's Clipboard. Is there a way to do this?
IE might allow that depending on the security settings
window.clipboar dData.setData(' Text', yourVariable)
<http://msdn2.microsoft .com/en-us/library/ms535220.aspx>
<http://msdn2.microsoft .com/en-us/library/ms536744.aspx>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 15 '07 #2
d d
JohnW-Mpls wrote:
I have some scripts that include a variable that I'd like to have js
copy to the Window's Clipboard. Is there a way to do this?
If you want to "borrow" some code to do it, I recommend going to
photobucket.com , click on one of the images from the main page. Once the
new page appears with that image, you'll see a form with "URL Link". If
you click on the link address, a little tooltip will appear that says
"Copied" and it's now in your clipboard.

That must be using a cross-browser method of copying to the clipboard
because it also works in Firefox. Until I noticed this (today
coincidentally) I thought it was only possible in IE.

~dd
Jul 15 '07 #3
d d wrote:
If you want to "borrow" some code to do it, I recommend going to
photobucket.com , click on one of the images from the main page. Once the
new page appears with that image, you'll see a form with "URL Link". If
you click on the link address, a little tooltip will appear that says
"Copied" and it's now in your clipboard.

That must be using a cross-browser method of copying to the clipboard
because it also works in Firefox. Until I noticed this (today
coincidentally) I thought it was only possible in IE.
They seeem to dynamically load a Shockwave Flash file which does the
copying to the clipboard. Does anyone know whether Flash can also read
from the clipboard? That would be a security problem.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 16 '07 #4
On Sun, 15 Jul 2007 10:32:53 -0500, JohnW-Mpls <jo*****@comcas t.net>
wrote:
>I'm new to JS.

I have some scripts that include a variable that I'd like to have js
copy to the Window's Clipboard. Is there a way to do this?

FWIW, I have the big O'Reilly book on JS but don't see what I want in
there (so far).

-
JohnW-Mpls

Finally, a simple one!

RE: Adding a JavaScript Copy to Clipboard function - 2/21/2007
2:31:22 horay for javascript.... why don't we use it???
here's a nice copy command you can use anywhere in script with a
variable or not.

window.clipboar dData.setData(' text',myVar);

where myVar is the variable being copied.

This works too...

window.clipboar dData.setData(' text','This has been copied to your
clipboard.');

-
JohnW-Mpls
Jul 20 '07 #5
On Jul 20, 4:14 pm, JohnW-Mpls <john...@comcas t.netwrote:
On Sun, 15 Jul 2007 10:32:53 -0500, JohnW-Mpls <john...@comcas t.net>
wrote:
I'm new to JS.
I have some scripts that include a variable that I'd like to have js
copy to the Window's Clipboard. Is there a way to do this?
FWIW, I have the big O'Reilly book on JS but don't see what I want in
there (so far).
-
JohnW-Mpls

Finally, a simple one!

RE: Adding a JavaScript Copy to Clipboard function - 2/21/2007
2:31:22 horay for javascript.... why don't we use it???
here's a nice copy command you can use anywhere in script with a
variable or not.

window.clipboar dData.setData(' text',myVar);

where myVar is the variable being copied.

This works too...

window.clipboar dData.setData(' text','This has been copied to your
clipboard.');

-
JohnW-Mpls
That's IE-only and will only work in certain security configurations.
IE7's default is to disallow clipboard access.

Jul 20 '07 #6
On Fri, 20 Jul 2007 13:40:50 -0700, David Mark
<dm***********@ gmail.comwrote:
>On Jul 20, 4:14 pm, JohnW-Mpls <john...@comcas t.netwrote:
>On Sun, 15 Jul 2007 10:32:53 -0500, JohnW-Mpls <john...@comcas t.net>
wrote:
>I'm new to JS.
>I have some scripts that include a variable that I'd like to have js
copy to the Window's Clipboard. Is there a way to do this?
-
JohnW-Mpls

Finally, a simple one!

window.clipboa rdData.setData( 'text',myVar);

where myVar is the variable being copied.
>That's IE-only and will only work in certain security configurations.
IE7's default is to disallow clipboard access.
Thanks for the forewarning - that is what happens for me - IE only.

The following is the code I inserted in my js program:

window.clipboar dData.setData(" text",unescapec (ks1));

I sure would like the code for all Browsers. I'm a SeaMonkey fan now.

-
JohnW-Mpls
Jul 25 '07 #7

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

Similar topics

0
2229
by: xyz | last post by:
I have a menu item to handle clipboard actions (cut, copy, paste). When I paste text that I copied from a Hungarian web page, the display looks normal on my RichTextBox, but the text retrieved from the clipboard is corrupted. For example, a U with double accent ( byte code x'FB' ) is replaced by a question mark in my txtEdit.Text after a Paste operation. It seems that the Clipboard.GetText() is changing the data. How is it possible to...
8
11472
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a database, and I need the data to be laid out in a tabular format, and set out in a specific way. At the current point in time, I am copy/pasting the raw text from the database into a table layout in InDesign. What I was thinking is that if I could...
7
11627
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
0
1902
by: James Russo | last post by:
Hello, I have an application which requires an image to be retrived from the clipboard. So, I am writting a quick C# windows application to take images from a webcam and store a single frame on the clipboard so it can be pasted into this other application. My solution is working fine with all applications (mspaint, word, wordpad) except the one I need it to work with. I've contacted the vendor of the application, but I haven't been able...
7
3845
by: Newbie | last post by:
How do I clear the clipboard in VB.NET 2003? TIA Newbie
15
12298
by: Peter Duniho | last post by:
I'm trying to use .NET and C# to draw a metafile copied to the clipboard by another application (Word 2003 in this case, but it shouldn't matter). I naively thought that I'd be able to use the Clipboard class to get an EnhancedMetafile or MetafilePict object from the Clipboard, use that to create a new Metafile object, and then draw that Metafile object using Graphics.DrawImage. It doesn't seem to be that simple.
1
18666
by: Figmo | last post by:
Wow.....this is darned odd.... I have an app that integrates with other applications. It registers a global hotkey with Windows. When the hotkey executes it sends a CTRL-C to the active window (any application) to copy whatever text is selected to the clipboard. It then issues a C# Clipboard.GetText(...) and does some processing with this string. All is good, no errors thus far.
8
2499
by: active | last post by:
Guess I'm looking for someone who likes to work difficult puzzles. I can't seem to ever retrieve a palette handle from the clipboard. Below is a simple test program that demonstrates the problem. The program uses windows api to get a handle to a palette from the clipboard. The palette needs to be put there by another program - maybe Photoshop.
20
7001
by: Joe Duchtel | last post by:
Hello - I have the following code to get a bitmap from the clipboard and to save it to a *.png file ... Dim lData As IDataObject = Clipboard.GetDataObject() If lData.GetDataPresent(DataFormats.Bitmap) Then Dim lPictureBox As New PictureBox
23
6277
by: Over | last post by:
Hi it's possible with language C, (Mingw or Djgpp) copying the clipboard of WinXp into file.txt? which function must be use. Thanks
0
9286
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
9156
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
9055
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,...
0
8997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7911
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6615
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
5939
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();...
0
4709
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2502
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.