Hi,
I noticed an interesting behaviour that HtmlUnit displays when I try
to get a page that has frames in it. The page consists of a frameset,
which in turn comprises of three frames in it.
<frameset id='Parent' name='Parent' rows='89,*' border=0
onload='if(self!=parent){top.location=window.location;}'>
<noframes>This page contains frames, please update your browser to
view this page.</noframes>
<frame name='Tabs' tabIndex=-1 scrolling='no' noresize target='main'
src='Page2.html'>
<frame name='Nav' scrolling='auto' noresize tabIndex=-1 target='Main'
src='Page3.html'>
<frame name='Main' noresize src='blankhtm.htm'>
</frameset>
Now, both Page2.html and Page3.html load up the same javascript source
file which upon loading up
1) finds out the frame in which it is currently loaded
2) executes some code meant specifically for the frame in 1.
Here's the javascript:
window.onload=function1;
function function1()
{
if(window.name=="Nav")
{
parent.frames['Main'].location="Page5.html";
}
if(window.name=="Tabs")
{
//some code
}
}
When HtmlUnit executes the javascript, it reports the following error:
org.mozilla.javascript.EcmaError: TypeError: Cannot set property
"location" of undefined to "Page5.html" (test.js#11)
However, if I make frame 'Main' appear before frame 'Nav' in the Html
above, I am able to successfully change the content of "Main" from
"Nav".
I presume that in the case where "Main" appears after "Nav", the
javascript in "Nav" executes even before "Main" could actually get
loaded and hence the error.
I was wondering if somebody had encountered this situation before and
if there has been a fix to this. I am using the latest source code
versions of HtmlUnit. And I didnt encounter this problem when I opened
the pages through IE and Mozilla
Regards
Vinay
|