[英]how to tell if a popup has fully loaded
Is it possible to tell from a parent window if a popup window has fully loaded? 是否可以从父窗口判断弹出窗口是否已完全加载?
<body>
<div id="btn">display web page</div>
<div id="somediv">
</div>
</body>
I write the following script to determine if the pop up is already loaded, but it does not work. 我编写以下脚本来确定弹出窗口是否已加载,但是它不起作用。
<script>
$("#somediv")[0].onload = function(){
alert('loaded');
console.log("rr");
};
</script>
Is this what you want? 这是你想要的吗?
<body>
<div id="btn">display web page</div>
<div id="somediv">
</div>
</body>
$("#somediv").load("a.html", function(){
alert('loaded');
console.log("rr");
});
https://jsfiddle.net/jboo92k4/1/ https://jsfiddle.net/jboo92k4/1/
Is this what you were looking for? 这是您要找的东西吗?
<html>
<head>
<script type="text/javascript">
var winPop;
function OpenWindow() {
winPop = window.open("popupwin.html");
CheckWinStatus();
}
function CheckWinStatus() {
try {
asdf = winPop.document.body;
WindowLoaded();
}
catch(e) {
setTimeout("CheckWinStatus()",1000);
}
}
function WindowLoaded() {
alert(winPop.document.title);
}
</script>
</head>
<body>
<form name="Form1">
<input type="button" name="B1" value="Open" onclick="OpenWindow()">
</form>
</body>
</html>
OpenWindow()
is called when button b1
is clicked. 单击按钮b1
时将调用函数OpenWindow()
。 OpenWindow()
, a popup window popupwin.html
is made to open. 在OpenWindow()
内部,将打开一个弹出窗口popupwin.html
。 CheckWinStatus()
checks whether the popup has fully loaded or not. CheckWinStatus()
检查弹出窗口是否已完全加载。 It has a timeout value of 1000 ms. 超时值为1000毫秒。 WindowLoaded()
is called. 弹出窗口完全加载后,将调用WindowLoaded()
。 This is where you would perform your popup dependent action. 您将在此处执行依赖于弹出窗口的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.