Home > ASP Development > copy image to clipboard

copy image to clipboard



Hello! I need help...



I need to disable the right click "copy" option on an ASP page and add a Copy button that will do the same thing.



I was able to disable the Copy when a user right clicks, but I need help copying the image to the clipboard when they click a button.



Please help!

    
Guest


hmm.. not sure how to do it but javascript should do it..

al the best

http://javascript.internet.com

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by icepricessa
hmm.. not sure how to do it but javascript should do it..

al the best

URL




Hey ZMan,



Did you get this to work? If so let me know how man.



I'm stressout out trying to do the same thing here.

Was this answer helpful ? Yes No   
Guest


Yep, I got it to work. Here is the javascript function. I could potentially have 2 images on a page that I need copied, so I pass a 0 or 1 to this function to get the right image out of the array.



[code]

<script language="JavaScript1.2">

// Copy button will put image on clipboard

function copyImage(sImage)

{



var oImg = document.images[sImage];

if (oImg) {

var range = document.body.createControlRange();

if (range) {

range.add(oImg)

range.execCommand('Copy');

document.selection.empty();

} else {

alert("Error! Cannot create range.")

}

} else {

alert("Cannot reference the specified image.");

}

}

</script>

Was this answer helpful ? Yes No   
Guest


nice code, just be aware that it's IE only code and won't work for non IE browser

such as Firefox.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved