I have two frames in a frameset - frame[0]
contains a script that loads a page into frame[1]
using
top.frames[1].location.href = '.html';
and then performs actions on that page, for example searching text within the page. I need the script to wait until page.html
has loaded in the second frame before doing this, and I can't use onload=...
in the second page because I have no control over its source.
Is there a way to do this?
I have two frames in a frameset - frame[0]
contains a script that loads a page into frame[1]
using
top.frames[1].location.href = 'http://some_location./page.html';
and then performs actions on that page, for example searching text within the page. I need the script to wait until page.html
has loaded in the second frame before doing this, and I can't use onload=...
in the second page because I have no control over its source.
Is there a way to do this?
Share Improve this question edited Nov 17, 2016 at 10:01 zb226 10.5k6 gold badges55 silver badges87 bronze badges asked Aug 5, 2009 at 8:59 Keir Finlow-BatesKeir Finlow-Bates 1,0652 gold badges15 silver badges27 bronze badges3 Answers
Reset to default 3use onload event of FRAME element
edit:
<frame onload = "if( top.frames[1].location.pathname == '/page.html' " ) alert( 'loaded' )";
or if you load different pages to the same frame use this:
<frame onload = "if( top.frames[1].location.pathname != 'about:blank' " ) alert( 'loaded' )";
or
<frame src = '/dummyInitial.html' onload = "if( top.frames[1].location.pathname != '/dummyInitial.html' " ) alert( 'loaded' )";
Well I do this, and it works.
var idInterval;
function callPage()
{ top.main.document.location.href = somepage.aspx;
document.getElementById('divLoading').style.visibility ="visible";
idInterval = setInterval("validaFrameMain()",50);
}
//look if the frame page is plete load
function validaFrameMain()
{
if (top.main.document.readyState != "plete")
{document.getElementById('divLoading').style.visibility ="visible";}
else
{ document.getElementById('divLoading').style.visibility ="hidden";;
clearInterval(idInterval);
idInterval = nothing;
}
}
If you have no control over the loaded page's source and more importantly, if it is ing from another domain, then there is only one answer:
You can't.
Interframe munication between different domains is NOT possible. And you need interframe munication because you would need something like jquery's ready function in the loaded page to determine if the entire page (the DOM) is loaded.