Sign in to follow this  
Followers 0
Veggie1232

click image to copy text to clipboard

5 posts in this topic

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!

Share this post


Link to post
Share on other sites

Ive not seen this for an image but the ones I have seen usually takes a textbox and copy the string value to the clipboard.

Share this post


Link to post
Share on other sites

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

Thanks

Share this post


Link to post
Share on other sites

If you want it to work properly across browsers - every solution I've seen resorts to flash :(.

2 people like this

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.