JavaScript IE FireFox onload

There are problems with FireFox using onload.  Most of the documentation and articles that I have read identifies that FireFox does not support onload.  I currently have FireFox 3 installed and onload seems to work.  But I have not been able to test onload on previous versions of FireFox.
 
I’m probably going to have to implement a solution for previous version of FireFox.  I have found some good reference of doing onload with previous version of FF, but do not have time to implement it right now.  I’m just going to put the references here so I can find them later.
 
 
BWCJP posted the following code at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2811631&SiteID=1
I believe the latest version of fire fox and likely the previous version require ‘document’ and not window as thats for IE and Opera accepts window also
//set page event handlers
if (window.attachEvent) {
  //IE and Opera
  window.attachEvent("onload", Page_Load);
  window.attachEvent("onunload", Page_Unload);
} else {
  //FireFox
  document.addEventListener("DOMContentLoaded", Page_Load, false);
  document.addEventListener("unload", Page_Unload, false);
}
 
Reference
Firefox IE7 onload event question
 
The window.onload Problem – Solved!

Leave a Reply

Your email address will not be published. Required fields are marked *