Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

document.body.onload in Firefox

Okay so I'm using Javascript to set the onload attribute of a page. It works in IE but not Firefox. Does anyone know a fix for this? Neither IE or Firefox is throwing an error. I'm using the Firefox plugin "Web Developer" and it isn't showing any JavaScript errors. Code below: Thanks.

document.body.onload = setRedirect;
function setRedirect()
{
    alert("TEST");
}
like image 341
jcmitch Avatar asked Feb 05 '26 07:02

jcmitch


1 Answers

Change to:

window.onload = setRedirect;

Also see this jsfiddle.

like image 136
scessor Avatar answered Feb 07 '26 19:02

scessor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!