gpt4 book ai didi

javascript - 如何停止来自 iframe 内容的 javascript 函数?

转载 作者:行者123 更新时间:2023-12-02 19:56:09 25 4
gpt4 key购买 nike

我正在为另一个网站构建 iframe。但他们的页面上有一个 javascript 函数,我不想在我的页面上执行。这是

if (top.location != location) {
top.location.href = document.location.href; }

我尝试过这个,但它停止了整个页面。

function StopLoading() {
if (!document.all)
{
window.stop();
}
else
{
window.document.execCommand('Stop');
}
}

<iframe id="i_frame" onload="StopLoading()" src="http://website.com/"></iframe>

最佳答案

由于标准浏览器安全限制,我不相信您可以执行此操作(假设涉及的 2 个站点位于不同的域中)。做到这一点的能力将为相当令人讨厌的事情带来可能性。您应该首先将另一个网站放入 iframe 中吗?

关于javascript - 如何停止来自 iframe 内容的 javascript 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8625297/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com