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

Yet another javascript function?

Status
Not open for further replies.

vongrunt

Programmer
Mar 8, 2004
4,863
HR
This probably doesn't belong to useful tips, so here comes a question: what does the following function?
Code:
<script language="javascript">
function blah()
{	with( arguments.length? arguments[0]: document.body)
		for (var i=0; i< childNodes.length; i++)
			with(obj = childNodes[i])
				nodeType==3? nodeValue=nodeValue.split(" ").reverse().join(" "): blah(obj);
}
</script>
Hint: paste it into any page you want (longer, more complex = better) and call from body onload.
 
Without running it (but scanning the function) it looks like it recursively parses the document, reversing the positions of all words (seperated by spaces) - not the letters that make up the words... just the words (as they appear in a sentence).

Jeff
 
I ran the code on NS7 - page is a very long credit application - didn't do anything. Page looks the same with or without.

There's always a better way. The fun is trying to find it!
 
I noticed that too - on some pages, in IE/Moz. Some sites are all in frames, some redefine window.onload handler on-the-fly... many possible reasons. On this page though (saved locally), works fine :).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top