bladechob Posted March 30, 2007 Share Posted March 30, 2007 Hi, what's the best way to protect source code on a page? I.e. not permitting the right mouse click to view source or properties. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/44940-solved-disabling-view-source-on-pages/ Share on other sites More sharing options...
stevesimo Posted March 30, 2007 Share Posted March 30, 2007 Use javascript onClick event handler to disable the right click There are plenty on the internet <script language=JavaScript> <!-- //this example is from www.dynamicdrive.com var message="Function Disabled!"; /////////////////////////////////// function clickIE4(){ if (event.button==2){ alert(message); return false; } } function clickNS4(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=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function("alert(message);return false") // --> </script> Hope this helps Steve (Blackpool) Quote Link to comment https://forums.phpfreaks.com/topic/44940-solved-disabling-view-source-on-pages/#findComment-218213 Share on other sites More sharing options...
bladechob Posted March 30, 2007 Author Share Posted March 30, 2007 Cheers Steve - nice one Quote Link to comment https://forums.phpfreaks.com/topic/44940-solved-disabling-view-source-on-pages/#findComment-218217 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.