Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Hide Your JavaScript With PHP!

Status
Not open for further replies.

smavtron

Technical User
Jul 28, 2007
17
US
We plan to use this script

Code:
How To Hide Your JavaScript With PHP!
 
On the page where the JavaScript is placed, add: 


<?
session_start();

if (!isset($_SESSION['access'])){
$_SESSION['access'] = true;
$access = 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($access)
{
header("Content-type: text/javascript");
?>
//any javascript can go in here
alert("woohoo it works at last!");
<?
$access = false;
}
?>

we want to add the javascript

<script type="text/javascript" src="
where it says

//any javascript can go in here

Can some one suggest how to do it.

TIA
 
Can some one suggest how to do it.

Suggest how to do what? No matter what you do any user can still view your derived code to get at your javascript. In order for your page to run the javascript it has to be downloaded to the user's computer - at which point they can get to it.

This has been discussed a bazillion times, always with the same outcome. It's not possible to hide your javascript. End of story.

Once you get everything all setup come put a little hidden comment into the javascript, come back and post the link here and we'll tell you what your hidden comment is just to prove it to you.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top