Thursday, June 01, 2006
Access Child Frame Elements
I've read that accessing frames is somewhat of a tricky business, especially when considering multiple browser support, which of course I want, because I always use Firefox and 90% or so of everyone else uses the dreaded Internet Explorer. If I want to use it and want others to use it, it has to be supported on both browsers (and hopefully khtml browsers as well).
A good parent frame element accessor I've used goes as follows:
parent.document.getElementById('elementId').value = "whatever";
I can even access a child frame:
frames['framename'].location.href="somepage.html";
But, I can't seem to get to elements, like input components, etc., inside of the child frame. Any advice on this challenge?
A good parent frame element accessor I've used goes as follows:
parent.document.getElementById('elementId').value = "whatever";
I can even access a child frame:
frames['framename'].location.href="somepage.html";
But, I can't seem to get to elements, like input components, etc., inside of the child frame. Any advice on this challenge?
Comments:
<< Home
Umm... did some tinkering around to see if I could do what you were wanting to do (or at least what I understood that you were wanting to do). It appears that you just need to have a "name" attribute on each of your frames within the frameset. In the javascript that you have you can access any frames with a name by saying "parent.framename" and going from there.
I was able to successfully add content to frames from links in other frames by doing something like:
parent.main.document.getElementById('element').innerHTML = "new text";
Chad can vouch for this :P Hope that helps.
Post a Comment
I was able to successfully add content to frames from links in other frames by doing something like:
parent.main.document.getElementById('element').innerHTML = "new text";
Chad can vouch for this :P Hope that helps.
<< Home