Disable right click - and source code view

Discussion in 'HTML' started by techfiddle, Oct 30, 2006.

  1. techfiddle

    techfiddle Guest

    Disabling the right click and hiding the source code view may be two
    entirely separate issues. I Googled disable right click and
    encountered three separate blocks of source code, none of which; worked
    on my page at http://www.geocities.com/techfiddle//policies.html

    I also searched in this group "disable right click" but the entires I
    got were very old, probably not effective any longer.

    I remember from the past there was very short snippet of code that
    worked, but now I can't find it. I don't care so much about hiding the
    source code (though that would be cool), as much as protecting my
    images.

    During the Googling (Ask, actually), there was a software program I
    could buy for $40 which accomplishes this:

    http://www.antssoft.com/htmlprotector/index.htm

    So do I need to buy something or is there html that will accomplish
    this?

    Thanks!
    Connie

    THREE BLOCKS OF SOURCE CODE THAT DID *NOT* WORK:

    <PRE>

    ______________________________


    <SCRIPT LANGUAGE="JavaScript1.1">
    <!-- Original: Martin Webb () -->

    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->

    <!-- Begin
    function right(e) {
    if (navigator.appName == 'Netscape' &&
    (e.which == 3 || e.which == 2))
    return false;
    else if (navigator.appName == 'Microsoft Internet Explorer' &&
    (event.button == 2 || event.button == 3)) {
    alert("I'm sorry, The Right click option on your mouse has been
    disabled for the download window pages.");
    return false;
    }
    return true;
    }

    document.onmousedown=right;
    document.onmouseup=right;
    if (document.layers) window.captureEvents(Event.MOUSEDOWN);
    if (document.layers) window.captureEvents(Event.MOUSEUP);
    window.onmousedown=right;
    window.onmouseup=right;
    // End -->
    </script>

    </head>



    ________________


    <SCRIPT language=JavaScript>
    <!-- http://www.spacegun.co.uk -->
    var message = "function disabled";
    function rtclickcheck(keyp){ if (navigator.appName == "Netscape" &&
    keyp.which == 3){ alert(message); return false; }
    if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {
    alert(message); return false; } }
    document.onmousedown = rtclickcheck;
    </SCRIPT>


    _____________________________



    <SCRIPT>function click() {if (event.button==2) {alert('Ooops...\nRight
    click is disabled!');}}document.onmousedown=click// - -></SCRIPT>




    ____________________________

    </PRE>
     
    techfiddle, Oct 30, 2006
    #1
    1. Advertising

  2. techfiddle

    Steve Pugh Guest

    techfiddle wrote:
    > Disabling the right click and hiding the source code view may be two
    > entirely separate issues.


    But they share some things in common:
    1. They don't work.
    2. They're pointless.
    3. They really don't work.

    > I Googled disable right click and
    > encountered three separate blocks of source code, none of which; worked


    Which browser are you using? Most modern browsers don't allow the page
    to disable basic browser functions like right click.

    > I also searched in this group "disable right click" but the entires I
    > got were very old, probably not effective any longer.


    Any techniques you found never were effective. Any advice you found to
    stop wanting to do this is still 100% valid.

    > I remember from the past there was very short snippet of code that
    > worked, but now I can't find it.


    It didn't work.

    > I don't care so much about hiding the
    > source code (though that would be cool), as much as protecting my
    > images.


    Don't put them on the web.

    Or hire a lawyer and enforce your copyright by taking legal action
    against people you steal your images.

    > During the Googling (Ask, actually), there was a software program I
    > could buy for $40 which accomplishes this:
    >
    > http://www.antssoft.com/htmlprotector/index.htm


    Anyone who buys that has just wasted $4. It does a good job of making
    your site inaccessible, but a poor job of protecting source code.

    > So do I need to buy something or is there html that will accomplish
    > this?


    Nothing you buy can do this. Nothing in HTML can do this.

    There are various JavaScript tricks that make it fractionally more
    difficult for clueless users to steal your images or code. But that's
    the best they can do.

    Steve
     
    Steve Pugh, Oct 30, 2006
    #2
    1. Advertising

  3. techfiddle wrote:
    > I remember from the past there was very short snippet of code that
    > worked, but now I can't find it. I don't care so much about hiding the
    > source code (though that would be cool), as much as protecting my
    > images.


    Try: rm -rf /home/techfiddle/public_html

    That will make your images safe!
     
    Leif K-Brooks, Oct 30, 2006
    #3
  4. You can't do that with HTML. To be honest I personally hate sites that
    disable right-click - there are many things I like to do with context menus
    that I don't think website owners should be attempting to block.

    +e

    "techfiddle" <> wrote in message
    news:...
    > Disabling the right click and hiding the source code view may be two
    > entirely separate issues. I Googled disable right click and
    > encountered three separate blocks of source code, none of which; worked
    > on my page at http://www.geocities.com/techfiddle//policies.html
    >
    > I also searched in this group "disable right click" but the entires I
    > got were very old, probably not effective any longer.
    >
    > I remember from the past there was very short snippet of code that
    > worked, but now I can't find it. I don't care so much about hiding the
    > source code (though that would be cool), as much as protecting my
    > images.
    >
    > During the Googling (Ask, actually), there was a software program I
    > could buy for $40 which accomplishes this:
    >
    > http://www.antssoft.com/htmlprotector/index.htm
    >
    > So do I need to buy something or is there html that will accomplish
    > this?
    >
    > Thanks!
    > Connie
    >
    > THREE BLOCKS OF SOURCE CODE THAT DID *NOT* WORK:
    >
    > <PRE>
    >
    > ______________________________
    >
    >
    > <SCRIPT LANGUAGE="JavaScript1.1">
    > <!-- Original: Martin Webb () -->
    >
    > <!-- This script and many more are available free online at -->
    > <!-- The JavaScript Source!! http://javascript.internet.com -->
    >
    > <!-- Begin
    > function right(e) {
    > if (navigator.appName == 'Netscape' &&
    > (e.which == 3 || e.which == 2))
    > return false;
    > else if (navigator.appName == 'Microsoft Internet Explorer' &&
    > (event.button == 2 || event.button == 3)) {
    > alert("I'm sorry, The Right click option on your mouse has been
    > disabled for the download window pages.");
    > return false;
    > }
    > return true;
    > }
    >
    > document.onmousedown=right;
    > document.onmouseup=right;
    > if (document.layers) window.captureEvents(Event.MOUSEDOWN);
    > if (document.layers) window.captureEvents(Event.MOUSEUP);
    > window.onmousedown=right;
    > window.onmouseup=right;
    > // End -->
    > </script>
    >
    > </head>
    >
    >
    >
    > ________________
    >
    >
    > <SCRIPT language=JavaScript>
    > <!-- http://www.spacegun.co.uk -->
    > var message = "function disabled";
    > function rtclickcheck(keyp){ if (navigator.appName == "Netscape" &&
    > keyp.which == 3){ alert(message); return false; }
    > if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {
    > alert(message); return false; } }
    > document.onmousedown = rtclickcheck;
    > </SCRIPT>
    >
    >
    > _____________________________
    >
    >
    >
    > <SCRIPT>function click() {if (event.button==2) {alert('Ooops...\nRight
    > click is disabled!');}}document.onmousedown=click// - -></SCRIPT>
    >
    >
    >
    >
    > ____________________________
    >
    > </PRE>
    >
     
    The Eclectic Electric, Oct 30, 2006
    #4
  5. techfiddle

    Guest

    On 30-Oct-2006, "techfiddle" <> wrote:

    > I don't care so much about hiding the
    > source code (though that would be cool), as much as protecting my
    > images.


    You might also have to think about Googles cache, of both pages
    and images.
     
    , Oct 30, 2006
    #5
  6. techfiddle

    John Dunlop Guest

    Leif K-Brooks:

    > Try: rm -rf /home/techfiddle/public_html
    >
    > That will make your images safe!


    Bush is trying to rm -f /bin/laden.

    Will that make his people safe?

    --
    Jock
     
    John Dunlop, Oct 30, 2006
    #6
  7. techfiddle

    techfiddle Guest

    >> Try: rm -rf /home/techfiddle/public_html

    You lost me...what is this?

    I'm using Mozilla.

    No, I distinctly remember that there was something. That worked. I
    was surprised none of the three I tried didn't work.

    I would be satisified to block the clueless.
     
    techfiddle, Oct 30, 2006
    #7
  8. techfiddle

    BootNic Guest

    > techfiddle <> wrote:
    > news:
    > Disabling the right click and hiding the source code view may be two
    > entirely separate issues. I Googled disable right click and
    > encountered three separate blocks of source code, none of which;
    > worked on my page at
    > http://www.geocities.com/techfiddle//policies.html
    >
    > I also searched in this group "disable right click" but the entires I
    > got were very old, probably not effective any longer.
    >
    > I remember from the past there was very short snippet of code that
    > worked, but now I can't find it. I don't care so much about hiding
    > the source code (though that would be cool), as much as protecting my
    > images.
    >
    > During the Googling (Ask, actually), there was a software program I
    > could buy for $40 which accomplishes this:
    >
    > http://www.antssoft.com/htmlprotector/index.htm
    >
    > So do I need to buy something or is there html that will accomplish
    > this?
    >

    [snip]
    Disable image right-click by capturing oncontextmenu.

    Bypass by
    - disabling JavaScript temporarily
    - using a browser that doesn't support oncontextmenu

    Javascript is usually used to add functionality to a site, when
    javascript is used to disable functionality, it becomes an annoyance.

    <script type="text/javascript">
    function annoyance1(e)
    {
    var elm=e.target||e.srcElement;
    if(elm.tagName.toLowerCase()=='img')
    {
    if(e.target)
    {
    e.preventDefault();
    e.stopPropagation();
    }
    else if(e.srcElement)
    {
    e.returnValue=false;
    }
    alert('WARNING:\n¯¯¯¯¯¯¯¯ \nWe have determined that right clicking '+
    'on images\nmay lead to unnecessary ware on your mouse.\n\nWe wou'+
    'ld like to encourage you to save your mouse.\n\nBy avoiding right clic'+
    'king images in the future, you may\nprevent the extinction of your m'+
    'ouse.\n\nThis message was brought to you by your friendly\nneighbor'+
    'hood webmaster.');
    }
    }
    if(window.attachEvent)
    {
    document.attachEvent('oncontextmenu',annoyance1);
    }
    else if(window.addEventListener)
    {
    document.addEventListener('contextmenu',annoyance1,null);
    }
    </script>

    --
    BootNic Monday, October 30, 2006 12:56 PM

    A well-developed sense of humor is the pole that adds balance to your
    step as you walk the tightrope of life
    *William Arthur Ward*
     
    BootNic, Oct 30, 2006
    #8
  9. techfiddle

    Bergamot Guest

    techfiddle wrote:
    >
    > I don't care so much about hiding the
    > source code (though that would be cool), as much as protecting my
    > images.


    Forget about trying to hide your source code. It is a wasted effort.

    Protect your images by putting a watermark on them.

    --
    Berg
     
    Bergamot, Oct 30, 2006
    #9
  10. techfiddle

    dorayme Guest

    In article
    <>,
    "techfiddle" <> wrote:

    > >> Try: rm -rf /home/techfiddle/public_html

    >
    > You lost me...what is this?
    >
    > I'm using Mozilla.
    >
    > No, I distinctly remember that there was something. That worked. I
    > was surprised none of the three I tried didn't work.
    >
    > I would be satisified to block the clueless.


    You want to hide stuff from the sort that would be unlikely to
    steal stuff from you to great effect?

    --
    dorayme
     
    dorayme, Oct 30, 2006
    #10
  11. techfiddle wrote:
    > >> Try: rm -rf /home/techfiddle/public_html

    > You lost me...what is this?
    > I'm using Mozilla.
    > No, I distinctly remember that there was something. That worked. I
    > was surprised none of the three I tried didn't work.


    Not having enough knowledge to make this work only proves that the
    level of your code sophistication is hardly worth stealing anyway.
    (hint... neither are your pictures)
     
    Travis Newbury, Oct 31, 2006
    #11
  12. techfiddle

    Cynode Guest

    On Mon, 30 Oct 2006 14:48:35 -0600, Bergamot <>
    wrote:

    >techfiddle wrote:
    >>
    >> I don't care so much about hiding the
    >> source code (though that would be cool), as much as protecting my
    >> images.

    >
    >Forget about trying to hide your source code. It is a wasted effort.


    make your website in flash, that will hide the code! lol.

    >Protect your images by putting a watermark on them.


    Yeah, pretty much the only way, and free advertising too!

    Basically the age old thing about pictures, music, and videos. if I
    can see it or hear it on my PC, there is a way for me to save it and
    takes it for my own.

    --
    If it keeps up, man will atrophy all his limbs but the push-button finger.
    ~Frank Lloyd Wright - www.cynode.com | www.cynode.net (NWS)
     
    Cynode, Oct 31, 2006
    #12
  13. Cynode wrote:
    > make your website in flash, that will hide the code! lol.


    Not even a little. It is simple to decompile Flash. Any good Flash
    developer knows their code is wide open to the world to see.
     
    Travis Newbury, Oct 31, 2006
    #13
  14. techfiddle

    Toby Inkster Guest

    BootNic wrote:

    > Bypass by
    > - disabling JavaScript temporarily
    > - using a browser that doesn't support oncontextmenu


    - using a browser that has an option to prevent scripts from
    capturing right clicks on a temporary or site-by-site basis
    (e.g. Opera).


    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Oct 31, 2006
    #14
  15. techfiddle

    BootNic Guest

    > Toby Inkster <> wrote:
    > news: 5n.co.uk
    > BootNic wrote:
    >
    >> Bypass by
    >> - disabling JavaScript temporarily
    >> - using a browser that doesn't support oncontextmenu

    >
    > - using a browser that has an option to prevent scripts from
    > capturing right clicks on a temporary or site-by-site basis
    > (e.g. Opera).


    The script does not capture right clicks, it adds/attaches to the
    oncontextmenu. Opera does not support oncontextmenu.

    --
    BootNic Tuesday, October 31, 2006 2:41 PM

    "Do not trust your memory; it is a net full of holes; the most
    beautiful prizes slip through it."
    *Georges Duhamel, The Heart's Domain*
     
    BootNic, Oct 31, 2006
    #15
  16. techfiddle

    richard Guest

    "techfiddle" <> wrote in message
    news:...
    > Disabling the right click and hiding the source code view may be two
    > entirely separate issues. I Googled disable right click and
    > encountered three separate blocks of source code, none of which; worked
    > on my page at http://www.geocities.com/techfiddle//policies.html
    >


    Do what ever you want. Just remember one thing. I have visited your site,
    therefor your images are already on my computer. If the image fits entirely
    on my screen, then I can simply print screen, save the image and edit as
    desired.
    Slap your domain name conspicously across the image to protect it from
    unauthorized use.
    Unless you personally took the image with your own camera, you do not own
    rights to that image.
     
    richard, Oct 31, 2006
    #16
  17. techfiddle

    techfiddle Guest

    richard wrote:
    > Unless you personally took the image with your own camera, you do not own
    > rights to that image.


    I paid someone to take the image. So I think I own the rights to it.

    This block of code may work:

    <script language=JavaScript>
    <!--

    //Disable right mouse click Script
    //By Maximus ()
    //For full source code, visit http://www.dynamicdrive.com

    var message="Sorry This function is disabled. The graphics and script
    on this page are not Public Domain and are not available for download
    or use.";
    ///////////////////////////////////
    function clickIE() {if (document.all) {alert(message);return false;}}
    function clickNS(e) {if
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {alert(message);return false;}}}
    if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

    document.oncontextmenu=new Function("return false")
    // -->
    </script>


    Not sure, about to try it. Which is from:

    http://www.sheilascorner.com/sheila.shtml

    Sheila's code is a total mystery to me.
     
    techfiddle, Nov 1, 2006
    #17
  18. techfiddle

    techfiddle Guest

    richard wrote:
    > Unless you personally took the image with your own camera, you do not own
    > rights to that image.


    I paid someone to take the image. So I think I own the rights to it.

    This block of code may work:

    <script language=JavaScript>
    <!--

    //Disable right mouse click Script
    //By Maximus ()
    //For full source code, visit http://www.dynamicdrive.com

    var message="Sorry This function is disabled. The graphics and script
    on this page are not Public Domain and are not available for download
    or use.";
    ///////////////////////////////////
    function clickIE() {if (document.all) {alert(message);return false;}}
    function clickNS(e) {if
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {alert(message);return false;}}}
    if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

    document.oncontextmenu=new Function("return false")
    // -->
    </script>


    Not sure, about to try it. Which is from:

    http://www.sheilascorner.com/sheila.shtml

    Sheila's code is a total mystery to me.
     
    techfiddle, Nov 1, 2006
    #18
  19. On 31 Oct 2006 richard wrote in alt.html

    >
    > Do what ever you want. Just remember one thing. I have visited your site,


    Hey, are you RtS? ;)

    --
    D?
    Yorkshire Pete
    http://yorkshirepete.com/
     
    Yorkshire Pete, Nov 1, 2006
    #19
  20. On 2006-11-01, techfiddle wrote:
    > richard wrote:
    >> Unless you personally took the image with your own camera, you do not own
    >> rights to that image.

    >
    > I paid someone to take the image. So I think I own the rights to it.


    That depends on the contract you signed; otherwise it belongs to
    the person who took it.

    > This block of code may work:
    >
    ><script language=JavaScript>
    ><!--
    >
    > //Disable right mouse click Script
    > //By Maximus ()
    > //For full source code, visit http://www.dynamicdrive.com
    >
    > var message="Sorry This function is disabled. The graphics and script
    > on this page are not Public Domain and are not available for download
    > or use.";
    > ///////////////////////////////////
    > function clickIE() {if (document.all) {alert(message);return false;}}
    > function clickNS(e) {if
    > (document.layers||(document.getElementById&&!document.all)) {
    > if (e.which==2||e.which==3) {alert(message);return false;}}}
    > if (document.layers)
    > {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    > else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
    >
    > document.oncontextmenu=new Function("return false")
    > // -->
    ></script>
    >
    >
    > Not sure, about to try it. Which is from:
    >
    > http://www.sheilascorner.com/sheila.shtml
    >
    > Sheila's code is a total mystery to me.


    Same here, but it doesn't prevent me fromn downloading any images
    from her page.

    --
    Chris F.A. Johnson <http://cfaj.freeshell.org>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
     
    Chris F.A. Johnson, Nov 1, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: How to disable right click mouse??

    Kevin Spencer, Jul 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    567
    Kevin Spencer
    Jul 24, 2003
  2. Desmond

    right click and view source

    Desmond, Mar 24, 2007, in forum: HTML
    Replies:
    13
    Views:
    617
    Neredbojias
    Mar 26, 2007
  3. Parthiv Joshi
    Replies:
    1
    Views:
    731
    Samuel L Matzen
    Jul 6, 2004
  4. yaktipper
    Replies:
    10
    Views:
    285
    Richard Cornford
    Jul 10, 2003
  5. hon123456
    Replies:
    4
    Views:
    220
    Christopher Benson-Manica
    Dec 20, 2005
Loading...

Share This Page