Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- HIding Javascript


usavetele - 4:01 pm on Jul 10, 2005 (gmt 0)


Ok, I've found the following for hiding Javascript, but it doesn't work for me. From the coding below, where does the second piece of coding go?

Here's what I found in an old Javascript forum, can't figure it out:

Don't want your javascript copied? Here's a very simple script that will hide it!

On the page where the javascript is placed, add:

<?
session_start();
if(!session_is_registered('allow_script'))
{
session_register('allow_script');
$allow_script = true;
}
?>
<html>
<head>
<script language="javascript" src="script.php"></script>
</head>
<body>
Body goes here...
</body>
</html>

And now create a new file called script.php and place your javascript there:

<?
session_start();
if($allow_script)
{
header("Content-type: text/javascript");
?>

alert("Woohoo! My javascript Works!");

<?
$allow_script = false;
}
?>


Thread source:: http://www.webmasterworld.com/php/9105.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com