我对JavaScript很陌生,我使用下面的代码输出警告框。我不知道为什么,但警告框似乎并不在该功能内部工作,但会在其外部非常愉快地工作。我将如何使它从这个函数内出现?iframe中的Javascript警报框
我觉得我还应该提到下面的代码是在iframe中执行的。
任何帮助,只能在赞赏
$(window).on('beforeunload', function() {
$(window).scrollTop(0);
});
function yourFunction(){
alert("Alert");
document.getElementById('iframeA').src = document.getElementById('iframeA').src
setTimeout(yourFunction, 3000);
}
function yourFunctionTwo(){
document.getElementById('iframeB').src = document.getElementById('iframeB').src
setTimeout(yourFunctionTwo, 4000);
}
yourFunction();
yourFunctionTwo();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<head>
</head>
<iframe id="iframeA" src="" height="50%" width="100%"></iframe>
<iframe id="iframeB" src="/sms/frames/tickerB.php" height="50%" width="100%" style="display: block; position: absolute;"></iframe>
<iframe id="iframeA" src="/sms/frames/tickerA.php" height="50%" width="100%" style="display: block; position: absolute;"></iframe>
</html>