Jump to content

[SOLVED] Do You Know How to do this . . . ?


Fluoresce

Recommended Posts

Does anyone know how to create a link which, when clicked, copies the anchor text to the user's clipboard and opens the destination in a new window? I also want a hover pop-up message to appear, saying something like: "Click to copy and visit site".

 

For example, picture this link:

 

<a href="webform.com">ID: 12345</a>

 

It will look like this on the page:

 

ID: 12345

 

When someone hovers over it, a message will appear next to it. For example:

 

ID: 12345 Click to copy your ID and open the Web form

 

Then, when the user clicks the link, ID: 12345 is copied to his/her clipboard and webform.com is opened in a new window.

 

I've seen this done before but I can't remember where. Anyone know how?

Link to comment
https://forums.phpfreaks.com/topic/154349-solved-do-you-know-how-to-do-this/
Share on other sites

There are examples of what I want on http://www.CouponCabin.com. Hover over the coupon codes and a pop-up message will appear. Then, if you click on a coupon code, the code will be copied to your clipboard and the site will be opened in a new window.

 

Anyone know how to do this?

Not tested but you could try this, or something similar..

 

In the head:

 

<script type="text/javascript">
function copyID(obj)
{
    var id = obj.innerHTML;
    id.execCommand('Copy');

    return true;
}
</script>

 

... and in the body:

 

<a href="webform.com" onclick="copyID(this);">ID: 12345</a>

 

As I said not tested!

 

Adam!

There are examples of what I want on http://www.CouponCabin.com. Hover over the coupon codes and a pop-up message will appear. Then, if you click on a coupon code, the code will be copied to your clipboard and the site will be opened in a new window.

 

Anyone know how to do this?

 

Why you don't look at couponcabin.com javascript to see how they done it ?

As far as I know, clipboard manipulation is only supported in Internet Explorer. I would guess that other browsers do not support it because of the obvious security issues. Some people may have sensitive data in their clipboard while browsing the web.

 

I am pretty sure it should be possible with Flash, though.

Thanks, Boom.dk.

 

After looking for a Flash answer, I found Zero Clipboard. It looks quite promising. However, as a complete newbie to both Flash and Javascript, I can't tell if it can be adapted to work in the way that I explained above.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.