如何在非活动的iframe中停止javascript ajax请求?

mck*_*ght 2 javascript ajax iframe jquery polling

我制作了网站,其中各种其他网页都是内置为"app"的i框架:

<iframe id="frame1" src="./app1.php">
<iframe id="frame2" src="./app2.php">
Run Code Online (Sandbox Code Playgroud)

在这些应用程序中,执行了javascript代码,其中包括非常频繁的HTTP请求.

$('#app1button').click(function () {
     //Here i have to stop the HTTP-Requests which where fired from the JS of App2
     hideAllApps();
     showApp(app1);
});
Run Code Online (Sandbox Code Playgroud)

app1非常频繁地从服务器轮询信息:

app1.php里面有Javascript ::

 Handler = window.setInterval(getStatus, 100); //start status messages
Run Code Online (Sandbox Code Playgroud)

当我现在点击app2时,另一个应用程序弹出,我想停止由于性能原因加载到app1.php中的javascript.

$('#app2button').click(function () {
    //Here i have to stop the HTTP-Requests which where fired from the JS of App1
    hideAllApps();
    showApp(app2);
});
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?你有什么想法?

提前致谢.

小智 5

在frame2中,您可以尝试window.parent.frame["frame1"].stop()在第1 帧中将stop()定义为清除间隔的函数.