PPRuNe Forums - View Single Post - read-only html, is it possible?
View Single Post
Old 15th Jun 2007, 02:25
  #7 (permalink)  
Atlas Shrugged
 
Join Date: Jan 2004
Location: Hiding..... in one hemisphere or another
Posts: 1,067
Received 1 Like on 1 Post
You can hide code from the web page source using the SRC attribute of <SCRIPT> tag.

Try this:

<SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT"
SRC="code.js">
<!--
//-->
</SCRIPT>

Here "code.js" is the name of the file containing your code. As evident from the SRC value, the file is located in the same directory as the html document. The file name can be whatever you decide but the extension must be ".js."

It’s not foolproof. Although the JavaScript code is not displayed when you view the page source, smart visitors can check their cache and find this external JavaScript file there.

Disabling the right-click function is about as useless as tits on a bull, but the code is:

<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function click(e)
{
var msg = "No right click is allowed";
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>
Atlas Shrugged is offline