• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

HTML/Java/?? Question.

Ren

Communist Nazi
Joined
Oct 26, 2001
Messages
2,247
Location
townsville.qld.au
Can someone please tell me the script rrequired to disable the "View Source" option? For those who don't know what that is, right click on this screen and select View Source (well it works with IE 5 anyway)

I'm glad the tech support forum came back (well it sorta did) :)
 
Just go to a web site with this option disabled and view its source! :lol: Then copy the script to your own web page.

Since it´s JavaScript it can easily be disabled by turning JavaScript off in your browser´s options. So it is really not foolproof in any way.
 
Originally posted by Hurricane
Just go to a web site with this option disabled and view its source! :lol: Then copy the script to your own web page.

Since it´s JavaScript it can easily be disabled by turning JavaScript off in your browser´s options. So it is really not foolproof in any way.
Yes, but if something is set so that the page does not load unless JS is on, then it serves its purpose.

I'm not sure of the exact code, but you could just remove the menu item. I don't think there is a "view source" shortcut, so this may work.

Actually, on second thoughts, this may be pretty easy to restore...
 
You cannot remove it. There is always a way round it. For example, you might see it removed from a menu, and the right-click menu disabled, but it's easy to bypass this by holding down space and right clicking a few times (or something like that).

The ONLY way to protect your code from people who know what they're doing is to write it server-side.
 
Make your site pop up to a window with no menu and no right click if you feel so inclined.
 
I agree with Pillager. A JavaScript will only block the casual user. Someone with even a basic understanding of HTML and programming can bypass such a block. So what you have to do is to make it server-side. For example, code it in PHP and have the html page fetch all data from a PHP file on the server.
 
Pop up is the only solution. No other way.
 
Woo-hoo someone agrees with me. :D

It is easy to get round no-right-click scripts. Also, correct me if I'm wrong, but a page with no password protection, with or without a view-source hide, could be loaded into an editor.

To hide your code from all but the most casual user, you have to do it server side.
 
Originally posted by Pillager
Woo-hoo someone agrees with me. :D

It is easy to get round no-right-click scripts. Also, correct me if I'm wrong, but a page with no password protection, with or without a view-source hide, could be loaded into an editor.

To hide your code from all but the most casual user, you have to do it server side.

Pop up is the client-side solution and its perfect :p
 
Below is a script for disabling right-click. (To get round it, just hold down RMB, then click 'OK' on the alert, then release the RMB, and there is the menu.)



script language="JavaScript">

var msg="mouse right click disabled.\n\n(or any message you want)";

function click(e) {
if (document.all) {
if (event.button == 2) {
alert(msg);
return false;
}
}

if (document.layers) {
if (e.which == 3) {
alert(msg);
return false;
}
}
}

if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;

</script>


If you combine this with a pop-up window, then you have a little protection against a beginner. If you need the code for a simple pop-up window with no chrome, try:

<a href="javascript:void(null)" onclick=window.open("Test.htm",null,"width=500,height=300,scrollbars=no,resizable=no,left=200,top=200");>Click Here</a>


Again, it is *very* easy to get round, though.
 
Back
Top Bottom