• 0

click image to copy text to clipboard


Question

Hello. I have a banner on my website and I want to make it so when you hover over the part with the IP text, it has a roll over effect that says something like (copy to clipboard). Then the user just clicks and the IP is copied to their clipboard.

 

Anyone have anything like this or a similar script? I am decent with html and css but that's about it. 

Here is a link to the banner in question: http://miningmojo.com/images/spotlight_sample.jpg

 

 

 

Thanks for any help!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I have hired someone to do this for me. If anyone is interested ill post the code once its finished.

Thanks

Link to comment
Share on other sites

  • 0

It's quite simple though the zclip plugin doesn't work for me from the zclip website itself but when ripped from their own example demo website it works >.>

$(".elementwithtext").zclip({
	path:'/js/ZeroClipboard.swf',
	copy: function() {
		return $(this).html();
	},
	afterCopy:function(){
		$(this).addClass("copied");
	}
});

The required jquery library: http://pastebin.com/Tw1bkrHC

 

Right click the image that doesn't load below, save it as image and rename it to swf for the swf file  ;)

 

Oh and in the case you use a image you can use the title attribute so something like this:

 

html:

<img src="someimage" title="texttocopy" />

jQuery:

$(".elementwithtext").zclip({
	path:'/js/ZeroClipboard.swf',
	copy: function() {
		return $(this).attr("title");
	}
});

@all

Yeah it always requires flash. Chrome, firefox, opera etc have disabled copy to clipboard in their browsers for security reasons, only internet explorer 8 and older are able to copy to clipboard with javascript. If anyone gets it to work with only javascript it means he found a security hole and at the moment the code is published the security flaw will be patched :p

post-367480-0-99972200-1394139057.jpg

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.