C
carlos
What I would like to do is set the focus on the first childNode
element of my iframe src page. I can't assume I know any of the id's
or content inside the iframe src. Therefore, what I would like to do
is walk the contents of the innerHTML, and when I come across an
input, image, button or any nodeType that can have focus, set the
focus, and stop tracersing the innerHTML. I started putting something
together, but it isn't working.. here is what I have so far.. Any of
you experts have any advice?
function setInnerFrameFocus(frameID) {
var frame
=document.getElementById(frameID.name).contentWindow.document;
var focusElements =
frame.documentElement.lastChild.childNodes;
for(n=0;n<focusElements.length;n++){ // walk through all
the focus element child nodes
for(i=0;i<focusElements[n].childNodes.length;i++){ check
the childnodes children for focus elements
//stop if a focus element is found
if((focusElements[n].childNodes.nodeName=="IMG") ||
(focusElements[n].childNodes.nodeName=="A") ||
focusElements[n].childNodes.nodeName=="INPUT") ){
//set the focus - not working though??
focusElements[n].childNodes.focus();
i=focusElements[n].childNodes.length;
}//end if
}
}
}
element of my iframe src page. I can't assume I know any of the id's
or content inside the iframe src. Therefore, what I would like to do
is walk the contents of the innerHTML, and when I come across an
input, image, button or any nodeType that can have focus, set the
focus, and stop tracersing the innerHTML. I started putting something
together, but it isn't working.. here is what I have so far.. Any of
you experts have any advice?
function setInnerFrameFocus(frameID) {
var frame
=document.getElementById(frameID.name).contentWindow.document;
var focusElements =
frame.documentElement.lastChild.childNodes;
for(n=0;n<focusElements.length;n++){ // walk through all
the focus element child nodes
for(i=0;i<focusElements[n].childNodes.length;i++){ check
the childnodes children for focus elements
//stop if a focus element is found
if((focusElements[n].childNodes.nodeName=="IMG") ||
(focusElements[n].childNodes.nodeName=="A") ||
focusElements[n].childNodes.nodeName=="INPUT") ){
//set the focus - not working though??
focusElements[n].childNodes.focus();
i=focusElements[n].childNodes.length;
}//end if
}
}
}