| | |
how does this work?
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
How to set this up?
source
http://www.tutorialized.com/tutorial...sing-PHP/16806
Unload Javascript Files
source
http://www.tutorialized.com/tutorial...sing-PHP/16806
Unload Javascript Files
•
•
•
•
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)
function unloadJS(scriptName) { var head = document.getElementsByTagName('head').item(0); var js = document.getElementById(scriptName); js.parentNode.removeChild(js); } function unloadAllJS() { var jsArray = new Array(); jsArray = document.getElementsByTagName('script'); for (i = 0; i < jsArray.length; i){ if (jsArray[i].id){ unloadJS(jsArray[i].id) }else{ jsArray[i].parentNode.removeChild(jsArray[i]); } } }
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.

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.
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:
if you've allready got some functions called in body onload; do this:
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.
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)
<body onload="hideAllJS();">
if you've allready got some functions called in body onload; do this:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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.
Plato forgot the nullahedron..
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)
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)
Plato forgot the nullahedron..
![]() |
Similar Threads
- Why won't this code work? (VB.NET)
- My nic card won't work! (*nix Hardware Configuration)
- Motorola T720 Phone and Verizon Wireless (Cellphones, PDAs and Handheld Devices)
- Can't get samba to work! (*nix Software)
- Mega Nerd (Geeks' Lounge)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Custom input tag?
- Next Thread: Moving iFrames
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser captcha captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu mp4 object onerror onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating stars synchronous toggle unicode variables w3c web webservice \n






