External javascript not "aware" of the DOM of parent document?
OK so I've got a document with an included .js file (<script type="text/javascript" src="foo.js" />)
I know that my functions are being called from the parent document, because if I put an alert as the first line of any given function, I get the little box.
BUT, if I try to do anything that access the elements in the parent document:
alert(document.getElementByID('bar').value);
Nothing happens. Nada.
Any ideas?
PS - the parent document happens to be XUL but I think that what applies to XHTML should also apply here since mozilla uses the same rendering code on the backend, more or less.
Have you looked at the JavaScript console?
I don't even know how to access the javascript console. :-)
In what way is the parent document XUL?
Simon? The <script> element lives in a XUL file, not an XHTML file. The namespace is XUL's, not XHTML's.
Dennis -
The console says document.getElementByID() is not a function.
WTF?
Isn't it getElementById (lower-case ending d)?
Yes, yes it is.
Good lord that was stupid of me.
In my defense, it should be ID.
:-)
I agree. Acronyms in camelcase are often a mess, and different vendors follow different "standards".
"In my defense, it should be ID."
IDentifier ??
Almost H. Anonymous
January 11th, 2006
Almost -
Whether or not it's logical form, "ID" has become the defacto acronym for Identification. Get over it, you smelly pedant.
Anyway you're ONLY being pedantic about this because it's ME. :-)
Certainly not.. I'm pendantic with everyone, just check out my posts on the main forum.
Almost H. Anonymous
January 11th, 2006
I've made that exact same mistake several times. Writing javascript is painful. The Venkman debugger helps a bit. Have a look if you want.
http://www.mozilla.org/projects/venkman/
sixtyten
January 11th, 2006
Does your IDE not have auto-correct for munged case? I try and avoid JS when possible and just use a vanilla editor when I do have to play with it, but I swear I used to use some editor or other that would fix stupid things like that...
I've never met an IDE I didn't hate.
"Good lord that was stupid of me."
"We're only human
Of flesh and blood we're made..."
Human League
January 12th, 2006