使用两个嵌套的iframe时阻止打开新选项卡 [英] Prevent opening new tab while using two nested iframes
问题描述
Hello stackoverflow fellas,我在这里面临一个问题。我给其他家伙提供了 iframe
代码,将其嵌入到他的网站上。
Hello stackoverflow fellas, I am facing a problem here. I gave a iframe
code to other fella to embed it on his website.
这是代码 iframe
:
Here is the code of iframe
:
<iframe height="100%" width="100%" frameborder="0" scrolling="auto" src="http://www.mywebsite.com/iframecode" type= "text/javascript"></iframe>
以上 iframe
包含以下内容 html
:
The above iframe
contains following html
:
<html>
<head>
</head>
<body>
//... some html code
<iframe src="http://www.paymentgatway.com/pay" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>
//... some html code
</body>
</html>
上面 html
包含另一个 iframe
用于支付(第三方)。
Here above html
contains another iframe
which is used to make a payment(third party).
问题:
所以问题是当他点击付费按钮时在第二个 iframe
中,它会将3D安全页面打开到新标签页,而不是将其打开到同一页面。
So the problem is when he clicks on pay button which is in second iframe
, it opens 3D security page to new tab instead of opening it to same page.
我在< head>
< base target =_ self/>
>我的iframe html的标签,但没有运气。
I have tried <base target="_self"/>
in <head>
tag of my iframe html, but no luck.
我已经测试直接使用付款iframe,当我点击付费按钮时它会打开窗口。
I have tested using payment iframe directly, when I click pay button it opens in same window .
请你能改变我的运气吗?
Please, can you change my luck?
推荐答案
我看到两件重要的事情:
I see two important things:
- Mixin
HTTP
withHTTPS
不是一个好习惯(除非你试图欺骗某人),即使你这样做,通常安全页面或浏览器也会阻止你。 - 如果
paymentgatway.com
已正确编码,那么它将不允许您加载iframe
安全原因
- Mixin
HTTP
withHTTPS
is not a good practice (unless you try to cheat someone) and even if you do, normally the secure page or the browser will block you. - If
paymentgatway.com
has been coded properly, then it will not allow you to load inside aniframe
for security reason
所以,基于:
我已经使用iframe直接测试,当我点击付费按钮
时,它会在同一个窗口中打开。
我会说你在这两种情况都面临。
结论:
除非您拥有这两个域并且可以修改 paymentgatway.com
的源代码,否则您不能这样做页面。
Conclusion:
You can't unless you own both domains and can modify the source code of paymentgatway.com
page.
这篇关于使用两个嵌套的iframe时阻止打开新选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!