Home > without mouse, without right click > “Save Image As” without Right Click using Javascript

“Save Image As” without Right Click using Javascript

<script>
function saveImageAs (imgOrURL) {
if (typeof imgOrURL == ‘object’)
imgOrURL = imgOrURL.src;
window.win = open (imgOrURL);
setTimeout(‘win.document.execCommand(“SaveAs”)’, 500);
}
</script>

<A href=”#”
ONCLICK=”saveImageAs(document.getElementById(‘embedImage’)); return false” >save image</A>

<img id=”embedImage” src=”impossible.jpg” >
I am not the author of this code and i am really not sure where i picked up this script. But it works too good… only on IE

  1. Jay
    December 10th, 2008 at 21:23 | #1

    add
    setTimeout(‘win.close()’, 500);
    after
    setTimeout(’win.document.execCommand(”SaveAs”)’, 500);
    so that the popup page closes automatically after saving.

  2. Jaya
    October 29th, 2009 at 06:00 | #2

    Thanks Jay.. It works!!

  3. joy
    May 4th, 2010 at 20:43 | #3

    hey
    i had try those, ya it works but where the image file was saved

  4. Dinesh
    June 5th, 2010 at 16:14 | #4

    I have tried the above scripts but it is throwing Access Denied error at

    I am using IE6.0 is there any specific reason for this. How to resolve this/how to achieve this?

    Please suggest me..

    Regards,
    Dinesh

  5. Dinesh
    June 5th, 2010 at 16:15 | #5

    @Jaya

    I have tried the above scripts but it is throwing Access Denied error at

    I am using IE6.0 is there any specific reason for this. How to resolve this/how to achieve this?

    Please suggest me..

    Regards,
    Dinesh

  1. April 19th, 2008 at 00:03 | #1