Mozilla + Firefox extension development

Thursday, November 04, 2004

Cannot get to elements inside an overlay during load time

With Firefox, it seems that elements inside an overlay cannot be referenced (by document.getElementById(...)) while the parent document hasn't been fully loaded. In fact, even inside an onload handler of the parent document, document.getElementById(...) still fails to return elements inside the overlay.

For initialization code (running at load time of your extension) that needs to reference elements inside an overlay, you need to hook up a load handler inside the overlay, as follows:

window.addEventListener("load", foo, false);
The function foo now can use document.getElementById(...) to get elements inside the overlay.

Mozilla doesn't seem to have this problem.


  • Are you sure it's not just the location of your script-element?
    I've found putting the script-tag at the overlay's end (which popular convention seemed to forbid) works nicely.

    By Anonymous rue, at 6:07 PM  

  • OK, I'll try that the next time. Thanks!

    By Blogger David Huynh, at 8:12 AM  

  • Greetings from North Cack-A-Lacky! I enjoyed your thoughts, although I give Firefox even a little more credit than you do, I think ;) See what I mean here: firefox security

    By Anonymous Anonymous, at 10:28 PM  

Post a Comment

<< Home