Disable Source View!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • crazybrumi
    replied
    this will work for firefox and ie.


    PHP Code:
    <script language=”JavaScript”>
    <!

    var message=";
    ///////////////////////////////////
    function clickIE()

    {if (document.all)
    {(message);return false;}}

    function clickNS(e) {
    if
    (document.layers||(document.getElementById&&!document.all))
    {
    if (e.which==2||e.which==3) {(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> 

    Leave a comment:


  • Nahar
    replied
    Originally posted by tkreturns View Post
    Many a times there is a situation where an organization wants no one to right click, copy and paste the page, print or view source etc. To achieve this one should deactivate the mouse right button and the keyboard right click button.
    But the same thing can be achieved with the help of the menu bar. We have to deactivate Alt key to restrict the user from accessing menu items.

    After doing this there is one more possibility from where the user can directly take the stuff from the page. Just use Ctrl + A to select the whole page and directly Ctrl + C, Ctrl + V to copy and paste respectively. This option must also be disabled.

    One more issue to take care is browser compatibility. It should work in Microsoft Internet Explorer and in Netscape Navigator.

    Here's the code:

    PHP Code:

    var isnn,isie
    if(navigator.appName=='Microsoft Internet Explorer'//check the browser
    {  isie=true }

    if(
    navigator.appName=='Netscape')
    {  
    isnn=true }

    function 
    right(e//to trap right click button 
    {
        if (
    isnn && (e.which == || e.which == ))
            return 
    false;
        else if (
    isie && (event.button == || event.button == 3)) 
        {
            
    alert("Sorry, you do not have permission to right click on this page.");
            return 
    false;
        }
            return 
    true;
    }

    function 
    key(k)   
    {
        if(
    isie) {
            if(
    event.keyCode==17 || event.keyCode==18 || event.keyCode==93) {
                
    alert("Sorry, you do not have permission to press this key."
                return 
    false;
             } 
        }

        if(
    isnn){
            
    alert("Sorry, you do not have permission to press this key."
            return 
    false; }   
    }

    if (
    document.layerswindow.captureEvents(Event.KEYPRESS);  
    if (
    document.layerswindow.captureEvents(Event.MOUSEDOWN);
    if (
    document.layerswindow.captureEvents(Event.MOUSEUP);
    document.onkeydown=key;  
    document.onmousedown=right;
    document.onmouseup=right;
    window.document.layers=right;
    Put this code in a file called security.js and reference it between the <HEAD> and </HEADtags of any html or asp page using: <Script language="JavaScript" src="security.js"></script
    Its JavaScript!
    Cheers!
    Nice Code But How With Mozilla Firefox Bro??
    With This Addons https://addons.mozilla.org/en-US/fir.../righttoclick/

    Stops javascript annoyances such as forbidden right click, forbidden text selection or cascading dialog boxes.

    Latest update: Check bottom link 'Older/other versions' !

    Leave a comment:


  • venko
    replied
    nice code bro. . .
    I'll try this. . :D

    Leave a comment:


  • tkreturns
    started a topic Disable Source View!

    Disable Source View!

    Many a times there is a situation where an organization wants no one to right click, copy and paste the page, print or view source etc. To achieve this one should deactivate the mouse right button and the keyboard right click button.
    But the same thing can be achieved with the help of the menu bar. We have to deactivate Alt key to restrict the user from accessing menu items.

    After doing this there is one more possibility from where the user can directly take the stuff from the page. Just use Ctrl + A to select the whole page and directly Ctrl + C, Ctrl + V to copy and paste respectively. This option must also be disabled.

    One more issue to take care is browser compatibility. It should work in Microsoft Internet Explorer and in Netscape Navigator.

    Here's the code:

    PHP Code:

    var isnn,isie
    if(navigator.appName=='Microsoft Internet Explorer'//check the browser
    {  isie=true }

    if(
    navigator.appName=='Netscape')
    {  
    isnn=true }

    function 
    right(e//to trap right click button 
    {
        if (
    isnn && (e.which == || e.which == ))
            return 
    false;
        else if (
    isie && (event.button == || event.button == 3)) 
        {
            
    alert("Sorry, you do not have permission to right click on this page.");
            return 
    false;
        }
            return 
    true;
    }

    function 
    key(k)   
    {
        if(
    isie) {
            if(
    event.keyCode==17 || event.keyCode==18 || event.keyCode==93) {
                
    alert("Sorry, you do not have permission to press this key."
                return 
    false;
             } 
        }

        if(
    isnn){
            
    alert("Sorry, you do not have permission to press this key."
            return 
    false; }   
    }

    if (
    document.layerswindow.captureEvents(Event.KEYPRESS);  
    if (
    document.layerswindow.captureEvents(Event.MOUSEDOWN);
    if (
    document.layerswindow.captureEvents(Event.MOUSEUP);
    document.onkeydown=key;  
    document.onmousedown=right;
    document.onmouseup=right;
    window.document.layers=right;
    Put this code in a file called security.js and reference it between the <HEAD> and </HEADtags of any html or asp page using: <Script language="JavaScript" src="security.js"></script
    Its JavaScript!
    Cheers!
Working...
X