Paste from clipboard when clipboard changes mid script

Discussion in 'Javascript' started by melvynm@gmail.com, Dec 13, 2004.

  1. Guest

    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.
     
    , Dec 13, 2004
    #1
    1. Advertising

  2. Ivo Guest

    <> wrote
    > 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 );

    --
    Ivo
     
    Ivo, Dec 14, 2004
    #2
    1. Advertising

  3. Guest

    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.
     
    , Dec 14, 2004
    #3
  4. Ivo Guest

    <> wrote
    > 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.
    --
    Ivo
     
    Ivo, Dec 14, 2004
    #4
  5. Randy Webb Guest

    wrote:

    > 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>

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Randy Webb, Dec 14, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MacDk
    Replies:
    0
    Views:
    437
    MacDk
    Jul 31, 2003
  2. =?Utf-8?B?ZnM=?=

    Paste from clipboard in asp.net

    =?Utf-8?B?ZnM=?=, Feb 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,919
    Ken Cox [Microsoft MVP]
    Feb 21, 2005
  3. Stephen Boulet

    Cut and paste to X clipboard?

    Stephen Boulet, Jun 25, 2004, in forum: Python
    Replies:
    3
    Views:
    547
    Stephen Boulet
    Jun 29, 2004
  4. puzzler
    Replies:
    0
    Views:
    743
    puzzler
    May 13, 2010
  5. tabonni
    Replies:
    1
    Views:
    195
    Jeff Cochran
    Sep 5, 2004
Loading...

Share This Page