943,942 Members | Top Members by Rank

Ad:
Jan 22nd, 2007
0

how does this work?

Expand Post »
How to set this up?



source
http://www.tutorialized.com/tutorial...sing-PHP/16806

Unload Javascript Files

Quote ...
I found this to be a neat little trick for hiding(somewhat) source javacscript code from peering eyes...

This function will unload all linked javascript files so that when you view source - you see no javascript files! (Especially helpful when using FF and using web-developer tools - no linked js files are displayed) The files remain resident in memory - allowing for the functions to work.

Just call the function in the tag

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function unloadJS(scriptName) {
  2. var head = document.getElementsByTagName('head').item(0);
  3. var js = document.getElementById(scriptName);
  4. js.parentNode.removeChild(js);
  5. }
  6.  
  7. function unloadAllJS() {
  8. var jsArray = new Array();
  9. jsArray = document.getElementsByTagName('script');
  10. for (i = 0; i < jsArray.length; i){
  11. if (jsArray[i].id){
  12. unloadJS(jsArray[i].id)
  13. }else{
  14. jsArray[i].parentNode.removeChild(jsArray[i]);
  15. }
  16. }
  17. }
Similar Threads
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005
Jan 29th, 2007
0

Re: how does this work?

Nice
How to use it ? just put the javascript in your page...


Don't work if you have firefox noscript extension, and blocking all javascript....turn off javascript and you will see the code.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
theonlydrayk is offline Offline
11 posts
since Jul 2006
Feb 2nd, 2007
0

Re: how does this work?

I meant does it go in Body, or Head? just with script tags? It dosent seem to do anything. Javascript is still visible via veiw source.
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005
Feb 5th, 2007
0

Re: how does this work?

you will have to add to the body onload event to call that function.

put the code within a script tag in the head section and change the opening body tag to say:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <body onload="hideAllJS();">

if you've allready got some functions called in body onload; do this:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <body onload="exampleFunction1(); exampleFunction2(); exampleFunctionETC(); hideAllJS();">

calling that function from any place other than body onload (which is called supposadly 'after' all loading has occured) may either have a detrimental effect on JS functions within a page; or fail to remove certain blocks.
Last edited by MattEvans; Feb 5th, 2007 at 9:24 am.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Feb 5th, 2007
0

Re: how does this work?

Ah I see. Ok thats simple enough. Was just curious about it. By the way Matt, Thanks Again For help, Really Appreciated!
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005
Feb 5th, 2007
0

Re: how does this work?

Still dosent seem to work, javascript still visible via veiw source (i assume this is where it hides it?)
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005
Feb 5th, 2007
0

Re: how does this work?

Sorry; the function name there is unloadAllJS not hideAllJS...

But..

It actually wont hide JS from the View Source in most browsers, Most browsers display the source code of the HTML page exactly as it was received (that is, irrespective of what Javascript subsequently does to the page)

The only thing it will hide is the display of Javascript elements in live DOM explorers like that which comes with Firefox... If you really want to hide JS functions; you should put them all in linked .js files and use the same kind of hotlink protection you would for images (conditional redirection at the server)
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Feb 5th, 2007
0

Re: how does this work?

Oh ok, I wondered why it was still visible lol. Bit of a pointless code eh. Oh well nevermind. Thanks again for info Mate!
Reputation Points: 11
Solved Threads: 6
Posting Whiz in Training
Inny is offline Offline
293 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Custom input tag?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Moving iFrames





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC