Results 1 to 3 of 3

Thread: Right Click Disable ( Annoy/Close)

  1. #1
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Right Click Disable ( Annoy/Close)

    1) CODE TITLE:
    Right Click Disable ( Annoy/Close)

    2) AUTHOR NAME/NOTES:
    Aimee Beery

    3) DESCRIPTION:
    This will give annoying messages to those who right click after last one webpage auto closes.

    4) URL TO CODE:

    or, ATTACHED BELOW (see #3 in guidelines below):

    Code:
    <script type="text/javascript"> 
    <!-- 
    var closeWin="1"; // Do you want to close window (1 for yes 0 for no) 
    var alertVis="1"; // Do you want to alert the visitor (1 for yes 0 for no) 
    var message="Right click disabled on images!"; // Your no right click message this line 
     
    /* 
    Disable right click script (Annoy-Close) 
    By Aimee Beery 
    */ 
     
    function detail(){ 
              if(alertVis == "1") alert(message);  
              alert("You like to right click?") 
              alert("How about left clicking?") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              alert("Left Click!") 
              if(closeWin == "1") self.close(); 
              return false; 
    } 
    function IE() { 
         if (event.button == "2" || event.button == "3"){detail();} 
    } 
    function NS(e) { 
         if (document.layers || (document.getElementById && !document.all)){ 
              if (e.which == "2" || e.which == "3"){ detail();} 
         } 
    } 
    document.onmousedown=IE;document.onmouseup=NS;document.oncontextmenu=new Function("return false"); 
     
    //--> 
    </script>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Javascript cannot close a window that wasn't opened with javascript.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This also shouldn't be done: it is not possible to fully prevent the user from right clicking (or at least it's not possible to prevent them from doing the same thing some other way, such as saving images or source code), and the only cases where this is an advantage to the user are pages where the right click has another function such as opening a menu. And in these cases, annoying the user is clearly not the intent.

    Though dynamic drive has some scripts like this (but none so aggressive), the current direction of the site is moving away from that.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •