我的框架集中有两个框架 - frame[0]
包含一个脚本,该脚本使用
frame[1]
中
top.frames[1].location.href = 'http://some_location.com/page.html';
然后在该页面上执行操作,例如在页面内搜索文本。我需要脚本等到 page.html
在第二个框架中加载后再执行此操作,并且我无法在第二个页面中使用 onload=...
因为我无法控制它的来源。
有办法做到这一点吗?
最佳答案
使用FRAME元素的onload事件
编辑:
<frame onload = "if( top.frames[1].location.pathname == '/page.html' " ) alert( 'loaded' )";
或者如果您将不同的页面加载到同一框架,请使用:
<frame onload = "if( top.frames[1].location.pathname != 'about:blank' " ) alert( 'loaded' )";
或
<frame src = '/dummyInitial.html' onload = "if( top.frames[1].location.pathname != '/dummyInitial.html' " ) alert( 'loaded' )";
关于javascript - 如何在一帧中获取JavaScript以等待页面在第二帧中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1232002/