I found the real culprit: timing!!! But not the solution.
function loadFrame()
{var frm=document.getElementById('frmtest');
frm.src='itest1.html';
if (frm.contentDocument)
alert(frm.contentDocument.getElementById('whatever').innerHTML);
else alert(frm.contentWindow.document.getElementById('whatever').innerHTML);
}
works only for the tiny example itest1.html that I presented, but
never for a more substantial itest1.html.
However it
always works after inserting a delay after loading and before accessing the elements as in the following example:
function loadFrame()
{var frm=document.getElementById('frmtest');
frm.src='itest1.html';
alert('delay'):
if (frm.contentDocument)
alert(frm.contentDocument.getElementById('whatever').innerHTML);
else alert(frm.contentWindow.document.getElementById('whatever').innerHTML);
}
Apparently the elements in itest1.html (such as id=whatever) do not exist immediately after the command frm.src=..., but only after a delay.
So maybe I should have rephrased my problem as "how to access the elements of a document loaded into an iframe" into "when(how) to access....".
Anybody recognizes this observation and how did you deal with it?
Thanks in advance......Eke