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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Silly tip - hiding comments

Status
Not open for further replies.

Niv3k

Programmer
Jul 11, 2001
350
US
I'm building a php/javascript page and I wanted to write some comments about my client side javascript code that I wanted "hidden" from browsers. Solution: Enclose the comments in php tags:

Code:
<? /*
   These are comments
*/ ?>

I know its not the most useful tip in the world, but a lot of times I want to put &quot;sensitive&quot; information inside of javascript comments, and this takes care of prying eyes.

Kevin
 
the only way to do that is creating .js files.

then you load them with
<script file=&quot;myjsfile.js&quot; language=&quot;javascript&quot;>

then you can access the functions in the file normaly. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
you can configurte the http server to don't show the js files. I didn't do that, yet, but it's possible.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
you were refering of the comments... ok that's way ...

this is to early to make me think. SOrry Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
If you download the .js file, like Sleidia said, one of two things will happen. If you have the .js file go through the php processor (by adding .js to the php config file) then the comments will be hidden. But if you do not have the .js go through the php processor then the php comments will show up.

So this tip CAN BE a security hole. But it can also be extremely useful.

I'm not sure however to completely prevent someone from downloading a .js file from the server without blocking the page the script is incuded on from being able to download it also. Any further info on that topic would be interesting...

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top