Forum Moderators: open

Message Too Old, No Replies

How do You Copy to Clipboard and Open a New Window?

         

Tehuti

11:21 am on Apr 19, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



On the Web site <snip>, when visitors click on a coupon code, the code is copied to their clipboard and the Web site is opened in a new window. What's more, if the visitor just hovers over the coupon code, a pop-up message appears, saying: "Click to copy code and open site."

Does anyone know how to do this? I have asked in two other Web master forums and nobody seems to know.

[edited by: whoisgregg at 9:18 pm (utc) on April 20, 2009]
[edit reason] No site specifics please, TOS #13 [/edit]

rocknbil

1:54 pm on Apr 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think this is only allowed for IE (security policy,) Google for "clipboard javascript" and you'll find lots of mini tutorials. Some of them claim the ability to work in NN/FF but it is supposed to prompt the user to allow clipboard manipulation, but I've never gotten them to play nicely.

However, if your task is only to copy text and place it in a new window, you could do it without copying to the clipboard. Something like

var targ = document.getElementByID('some-textfield').value;

Then you open the new window and either document.write() or populate a form field value in the new window with the value of targ.

Tehuti

3:07 pm on Apr 19, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



I think this is only allowed for IE (security policy,) Google for "clipboard javascript" and you'll find lots of mini tutorials.

Thanks, Rocknbil.

I searched all over the Web before I asked for help. I am aware that the copy-to-clipboard function mainly works for IE. However, the way in which it is done at <snip> seems to work just fine with Firefox and other browsers.

Have you any idea as to how it's done?

[edited by: whoisgregg at 9:22 pm (utc) on April 20, 2009]
[edit reason] No site specifics please, see TOS #13 [/edit]

Rambo Tribble

5:34 pm on Apr 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I haven't tried this, but I found it searching on "firefox clipboard": [febooti.com...]

It seems there is also a Flash-based work-around.

[edited by: Rambo_Tribble at 5:36 pm (utc) on April 19, 2009]

Tehuti

5:46 pm on Apr 19, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks, Rambo Tribble, but that just enables the function in my browser. I have already come across that page.

I will look into the flash-based method that you mentioned. In the mean time, if anyone can work out how it's done <snip>, I will appreciate it very much.

[edited by: whoisgregg at 9:19 pm (utc) on April 20, 2009]
[edit reason] No site specifics please, TOS #13 [/edit]

whoisgregg

3:04 pm on Apr 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Flash is required to offer this feature reliably across different browsers. However, there are many helper flash files that no longer work with the newest version of Flash. If you do a search for "javascript copy clipboard flash 10" you should be able to find a solution (and plenty of discussion on the Flash 10 issue).

Tehuti

10:10 am on Apr 21, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks, Whoisgregg.

And sorry for giving you the extra work of having to "snip" my references to that Web site. Referring to it made things much easier. I didn't realise that I was still breaking a rule.

whoisgregg

3:16 pm on Apr 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Happy to help, Tehuti. :)

You should check your inbox [webmasterworld.com], I've sent you a couple sticky mails. :)