getElementById() returns null
I got a problem with getElementById().
Using it the way it's used here
works fine (i.e. getting an element with a script defined on the same page as the element it's looking for).
But if I try to call it from e.g. a FireFox extension plug-in to get hold of an element on a page that I didn't write myself, then it always returns null.
Here's another example:
If I use the DOM Inspector to look up the id of an element on a random page and then use the Execute JS to execute this simple code
were theId is the id I looked up and executed in the context of the page with that id, it always returns null. Still, calling
gives the title of that page!
What is it I don't get?
Last edited by .:Meero:.; 04-15-2009 at 09:35 AM.
Last edited by ZeroKilled; 05-08-2009 at 11:20 PM.
Thought I tried checking "Content Window", but apparently not.
Still, got the same problem with my FireFox extension script. I assume there's some call I need to make that has the same effect as checking the "Content Window"?
doubt it, i typed directly document.getElementById and returned me correct element. however, not sure but guess this is the similar effect as if Content Window were marked:
Aha! That seems to do the trick.
now gives a nice HTML dump of the "posts" DIV element of this forum page.
var e = getBrowser().contentWindow.document.getElementById('posts');
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread