Javascript: how to block the right mouse button

    Javascript: how to block the right mouse button

    Here is a simple script to lock the right mouse button on a web page.



    ONE JAVASCRIPT PER WEEK - practical demonstration

       
      
        A:link, A:visited { text-decoration: none }
      
        A:hover { text-decoration: underline }
      
       

    function article (str) {

            searchWin = window.open(str,’articolo’,’scrollbars=no,
    resizable=yes,width=485,height=300,status=no,location=no,toolbar=no’);

    //        searchWin.refer = self;

    }




    <!– 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 (“Sorry, the right mouse button is disabled”);
    return false;
    }
    return true;
    }

    document.onmousedown = right;
    if (document.layers) window.captureEvents (Event.MOUSEDOWN);
    window.onmousedown = right;
    //  End –>




    Try clicking the right mouse button

    Hello

    add a comment of Javascript: how to block the right mouse button
    Comment sent successfully! We will review it in the next few hours.