Disable Source View!

Started on the old forum in February 2011 · view the original in the archive · old links redirect here

33 replies · 2,451 views · started 15 years ago · 2 min read

17 participants
tkreturns Developer · 98 posts #1

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:

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 == 3 || e.which == 2 ))
		return false;
	else if (isie && (event.button == 2 || 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.layers) window.captureEvents(Event.KEYPRESS);  
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.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 </HEAD> tags of any html or asp page using: <Script language="JavaScript" src="security.js"></script> 

Its JavaScript! Cheers!

ASK FOR HELP

Nahar Developer · 196 posts #3

tkreturns wrote: 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:

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 == 3 || e.which == 2 ))
		return false;
	else if (isie && (event.button == 2 || 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.layers) window.captureEvents(Event.KEYPRESS);  
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.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 </HEAD> tags 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/firefox/addon/righttoclick/

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

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

crazybrumi Super moderator Principal · 1,064 posts #4

this will work for firefox and ie.

<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>

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

Nahar Developer · 196 posts #5
<?php function dimensi_Footer() { ?> <script type="text/javascript"> disableSelection(document.body) </script> <?php } function dimensi_Disable_Right_Click($dimensi_Message) {?> <meta http-equiv="imagetoolbar" content="no"> <script type="text/javascript" language="JavaScript"> function disableText(e){ return false } function reEnable(){ return true } //For browser IE4+ document.onselectstart = new Function ("return false") //For browser NS6 if (window.sidebar){ document.onmousdown = disableText document.onclick = reEnable } </script> <script language="JavaScript1.2"> var msgpopup="<?php echo $dimensi_Message; ?>"; function dimensi(){ if(alertVis == "1") alert(message); if(closeWin == "1") self.close(); return false; } function IE() { if (event.button == "2" || event.button == "3"){dimensi();} } function NS(e) { if (document.layers || (document.getElementById && !document.all)){ if (e.which == "2" || e.which == "3"){ dimensi();} } } document.onmousedown=IE;document.onmouseup=NS;document.oncontextmenu=new Function("alert(msgpopup);return false") </script> <?php } function dimensi_Disable_Selection() { ?> <script type="text/javascript"> function disableSelection(target){ if (typeof target.onselectstart!="undefined") //For IE target.onselectstart=function(){return false} else if (typeof target.style.MozUserSelect!="undefined") //For Firefox target.style.MozUserSelect="none" else //All other route (For Opera) target.onmousedown=function(){return false} target.style.cursor = "default" } </script>

?>

Try This Also..m Use At my site..Just Modify This Code 🙂

tkreturns Developer · 98 posts #7

hmm

khan89 wrote: ctr + u.....

<script language="JavaScript">
function disableCtrlAltrKeyCombination(e)
{
        var ctrlu='u';
        var altrs='s';
        var key;
        var isCtrl;
        var isAltr;

//For Ctrl
//For Internet Explorer

        if(window.event)
        {
                key = window.event.keyCode;
                if(window.event.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }
//For Firefox
        else
        {
                key = e.which;     //firefox
                if(e.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }

//For Alter
//For Internet Explorer
        if(window.event)
        {
                key = window.event.keyCode;     //IE
                if(window.event.altrKey)
                        isAltr = true;
                else
                        isAltr = false;
        }
//For Firefox
        else
        {
                key = e.which;     //firefox
                if(e.altrKey)
                        isAltr = true;
                else
                        isAltr= false;
        }

//Check For CTRL+U
        if(isCtrl)
        {
		if(ctrlu.toLowerCase() == String.fromCharCode(key).toLowerCase())
		{
                		alert(‘Key combination CTRL + U has been disabled.’);
		}
                return false;
        }

//Check For ALTR+S
        if(isCtrl)
        {
                if(altrs.toLowerCase() == String.fromCharCode(key).toLowerCase())
		{
                		alert(‘Key combination ALTR + S has been disabled.’);
		}
                return false;
        }
        return true;
}
</script>

<input type="text" name="mytext" onKeyPress="return disableCtrlAltrKeyCombination(event);" onKeyDown="return disableCtrlAltrKeyCombination(event);" />

here you go mate .

ASK FOR HELP

metulj Super moderator Principal · 1,726 posts #8

hmmm... i'd like to test something... so whoever use any of the above code.. post link here so i can check if you can really disable source view 🙂

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

subzero Super moderator Fellow · 3,954 posts #9

They cant lmao

Use other sites there alot of scripts here they can use to see your scripts Mahahahahaha

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

wap2k Developer · 168 posts #10

No matter how hard you try; there is always the browser cache there is no way to stop that. Also Telnet, C/C++/c#/VB via Windows Sockets or I-Net Libs. Online source code viewers. This list could go on and on for days is there really a point with protecting it. JavaScript in Opera can just be turned of with a tick box for that specific site i guess it is true for other browsers.

frostymarvelous Senior · 266 posts #11

You're talking too complex, just come down a little. A simple javascript disable will make the script useless. I've done that on a couple of sites.

Perfection comes at a cost

I accept liberty!

jhero14 Junior · 20 posts #12

..oh im sory to tell you guyz..but all code posted did nothing..you can alwayz view the source..many wap site using the php source viewer..

Mysterio Lead · 630 posts #13

And it's as easy as hell. We can't hide source-code and I hate this fact.

mysterio.al - programming is a functional art

fyzan Newbie · 1 posts #14

Encrypt Source

Extract encrypt.zip to your web server and Just put include 'encrypt.php'; in the beginning of your web page script. The HTML content will be automatically encrypted via Base64 algorithm so nobody can view it

Attachments: encrypt.zip
CreativityKills Lead · 833 posts #15

fyzan wrote: Extract encrypt.zip to your web server and Just put include 'encrypt.php'; in the beginning of your web page script. The HTML content will be automatically encrypted via Base64 algorithm so nobody can view it

base64 can be decrypted with one line of code. :-/

subzero Super moderator Fellow · 3,954 posts #17

i got a html encoder that will block being copyed or see its script..

And it can't not be decoded not at all..

1 problem thou php scripts that need $user_tables and sql then your site will not run it will just shows $user_tables and mysql

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

tkreturns Developer · 98 posts #18

i had seen in someones site most probably amylee's site when i clicked the view source , it said Pssst in the source 🙂

ASK FOR HELP

wap2k Developer · 168 posts #19

subzero wrote: i got a html encoder that will block being copyed or see its script..

And it can't not be decoded not at all..

1 problem thou php scripts that need $user_tables and sql then your site will not run it will just shows $user_tables and mysql

There would be no way to do one way html encrytion..... So i call bul**** on that. If so prove it lol.

tkreturns wrote: i had seen in someones site most probably amylee's site when i clicked the view source , it said Pssst in the source :)

This is a visual trick were returns are used befor the source lol..... If you had scroll the page down the code was there.

The Client (Browser) Requires HTML/TXT to render any page so hiding it in some ways is a complete waste of time.

subzero Super moderator Fellow · 3,954 posts #20

No there is a encoder that blocks sites

and it can not be decoded the site also says encode always back up the real code first....

Added after 5 minutes:

Word

Well+done+you+win+a+....+Oh+Crap+i+forgot...

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close