View Full Version : HTML/Java/?? Question.
Ren Jun 19, 2002, 01:02 AM 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) :)
Hurricane Jun 19, 2002, 01:41 AM 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.
ainwood Jun 19, 2002, 02:05 AM 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...
Pillager Jun 19, 2002, 08:11 AM 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.
IceBlaZe Jun 19, 2002, 10:44 AM Make your site pop up to a window with no menu and no right click if you feel so inclined.
Hurricane Jun 20, 2002, 06:03 AM 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.
IceBlaZe Jun 20, 2002, 07:06 AM Pop up is the only solution. No other way.
Pillager Jun 20, 2002, 10:32 AM 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.
IceBlaZe Jun 20, 2002, 10:39 AM 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
Ren Jun 21, 2002, 12:15 AM Trust me, it's a private site and the people i'm blocking have little to no experience.
Pillager Jun 21, 2002, 03:26 AM 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,le ft=200,top=200");>Click Here</a>
Again, it is *very* easy to get round, though.
|
|