Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.