Java script people, can you help me decode this bit of code?

Maximus96

Diamond Member
Nov 9, 2000
5,388
1
0
document.write("<div id=_p_></div>");window.onload=function(){try{var u=document.body.getAttribute("unload");if(u)eval(u);}catch(e){}};

It looks like every time I go on the net with firefox at work it will first go to 1.2.3.0

So I was wondering what that was and typed that into the address bar. That's when I see the code above. It looks to me its gathering my info and writing it to a file. Can somebody tell me exactly what info its gathering?

Thanks
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Two functions here:

document.write("<div id=_p_></div>") does nothing. Writes an empty <div> tag.

window.onload=function(){try{var u=document.body.getAttribute("unload");if(u)eval(u);}catch(e){}};

Retrieves the contents of the unload attribute from the <body> tag in your HTML. If there is an unload function defined, that function is then executed. The code is executed when the window is loaded.
 

nakedfrog

No Lifer
Apr 3, 2001
62,283
18,164
136
Originally posted by: MrChad
Two functions here:

document.write("<div id=_p_></div>") does nothing. Writes an empty <div> tag.

window.onload=function(){try{var u=document.body.getAttribute("unload");if(u)eval(u);}catch(e){}};

Retrieves the contents of the unload attribute from the <body> tag in your HTML. If there is an unload function defined, that function is then executed. The code is executed when the window is loaded.

And then we fire ze missiles.
 

Beev

Diamond Member
Apr 20, 2006
7,775
0
0
The residents of AT fought long and hard for a programming forum!
 

Maximus96

Diamond Member
Nov 9, 2000
5,388
1
0
Originally posted by: MrChad
Two functions here:

document.write("<div id=_p_></div>") does nothing. Writes an empty <div> tag.

window.onload=function(){try{var u=document.body.getAttribute("unload");if(u)eval(u);}catch(e){}};

Retrieves the contents of the unload attribute from the <body> tag in your HTML. If there is an unload function defined, that function is then executed. The code is executed when the window is loaded.

Thanks for your help. But I still don't understand what exactly does it do? What is the unload attribute?
 

Train

Lifer
Jun 22, 2000
13,584
81
91
www.bing.com
Originally posted by: Beev
The residents of AT fought long and hard for a programming forum!

Yes they/we did!

And IMO idle topics hang out on page one way too long for a board with as many techie members as this one.

 

FeuerFrei

Diamond Member
Mar 30, 2005
9,144
929
126
Originally posted by: Maximus96
Originally posted by: MrChad
Two functions here:

document.write("<div id=_p_></div>") does nothing. Writes an empty <div> tag.

window.onload=function(){try{var u=document.body.getAttribute("unload");if(u)eval(u);}catch(e){}};

Retrieves the contents of the unload attribute from the <body> tag in your HTML. If there is an unload function defined, that function is then executed. The code is executed when the window is loaded.

Thanks for your help. But I still don't understand what exactly does it do? What is the unload attribute?
If assigned a value, it names a function/procedure to call when the page body is unloaded from the browser window. What actually happens depends on what the function was written to do.