如何停止在非活动的Iframe的JavaScript Ajax请求? [英] How to stop javascript ajax requests in inactive Iframe?

查看:114
本文介绍了如何停止在非活动的Iframe的JavaScript Ajax请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了网站,在那里各种其他页面是内置的应用程序与I帧:

I have made Website, where various other pages are built-in as "apps" with i frames:

<iframe id="frame1" src="./app1.php">
<iframe id="frame2" src="./app2.php">

在这些应用程序,有执行,其中包括非常高频繁的HTTP请求的Jav​​aScript code。

In these apps, there is javascript code executed, among others very high-frequent HTTP-Requests.

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

APP1是从服务器非常高的频繁查询的信息:

app1 is polling information from a server very high frequently:

app1.php有Javascript语言,它::

app1.php has Javascript in it::

 Handler = window.setInterval(getStatus, 100); //start status messages

当我现在点击APP2,其他应用程序弹出了,我想停下来的JavaScript,这是装在app1.php,由于性能方面的原因。

When i now click on app2, the other app pops up, and i want to stop the javascript, which was loaded in app1.php, due to performance reasons.

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

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

How can i do that? Do you have any ideas?

在此先感谢。

推荐答案

从内帧2,你可以尝试 window.parent.frame [帧1。停止()并在第1帧定义的stop()作为一个函数,它会清除你的时间。

From within frame2 you can try window.parent.frame["frame1"].stop() and in frame 1 you define stop() as a function which clears your interval.

这篇关于如何停止在非活动的Iframe的JavaScript Ajax请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆