Paste from clipboard when clipboard changes mid script

M

melvynm

In the middle of my script the clipboard contents change (I'm opening a
site which immediately copies a variable to the clipboard). How do I
use this variable in my script?

If I declare:
var p = window.clipboardData.getData('text');
at the beginning, then:
p = clipboard at start of script
and does not take note of changes.
 
I

Ivo

In the middle of my script the clipboard contents change (I'm opening a
site which immediately copies a variable to the clipboard).

That is not going to be a popular site then. The clipboard is generally seen
as a very private thing, and the fact that jscript can tinker with it so
easily is not OK.
How do I use this variable in my script?

If I declare:
var p = window.clipboardData.getData('text');
at the beginning, then:
p = clipboard at start of script
and does not take note of changes.

Not sure what you mean. The variable is a variable like any other. You may
even assume it is of type string. Try:

alert( 'Look what I found on your clipboard:\n\n' + p );
 
M

melvynm

Actually, it's a very popular site. The site is www.tinyurl.com. Users
of this free service go there to convert very long URLs into more
memorable/emailable ones by receiving pointers from them. When the
pointer is created it is automatically copied to the clipboard as that
is the only logical thing a user is going to want to do with it.
Also, those of us using clipboard managers aren't too bothered if a new
entry is made as it doesn't wipe out the existing one.
To return to the topic I'm trying to create a script which opens
tinyurl.com and then takes the new clipboard item as the message body
of an email. The problem is that the only way I know to use the
clipboard contents is to use:
var p = window.clipboardData.getData('text');
then use 'p' as my clipboard contents. When I do so I only get the
clipboard data that was there at the start of the script and not that
which gets written halfway through.
 
I

Ivo

Actually, it's a very popular site. The site is www.tinyurl.com. Users
of this free service go there to convert very long URLs into more
memorable/emailable ones by receiving pointers from them. When the
pointer is created it is automatically copied to the clipboard as that
is the only logical thing a user is going to want to do with it.
Also, those of us using clipboard managers aren't too bothered if a new
entry is made as it doesn't wipe out the existing one.

Don't know what a clipboard manager is, sounds disturbing.
To return to the topic I'm trying to create a script which opens
tinyurl.com and then takes the new clipboard item as the message body
of an email.
The problem is that the only way I know to use the
clipboard contents is to use:
var p = window.clipboardData.getData('text');
then use 'p' as my clipboard contents. When I do so I only get the
clipboard data that was there at the start of the script and not that
which gets written halfway through.

So I understand your script is not going to come from the same domain>
scripts like reading the clipboad periodically (using setInterval) so you
can find out when it's changed by tinyurl.com, are going to suffer from
cross-domain security issues.
 
R

Randy Webb

Actually, it's a very popular site. The site is www.tinyurl.com. Users
of this free service go there to convert very long URLs into more
memorable/emailable ones by receiving pointers from them. When the
pointer is created it is automatically copied to the clipboard as that
is the only logical thing a user is going to want to do with it.

Correction:

It is only copied to the clipboard if the user is using IE4+ on Windows.

To quote the tinyURL site:

<quote>
Note: For IE 4+ on Windows, the TinyURL is automatically copied to your
clipboard and is ready for pasting (using Ctrl-V).
</quote>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,208
Latest member
RandallLay

Latest Threads

Top