简体   繁体   English

阻止iframe重新加载父级

[英]Prevent Iframe from Reloading the Parent

I have a Page with standard iframe markup 我有一个带有标准iframe标记的页面

Inside the frame is Linked to a Https URL The iframe does some processing (payment info and such) 框架内部链接到Https URL iframe进行了一些处理(付款信息等)

Then returns back a POST data When the processing fails most of the time it does not reload the parent( Return url, plus POST data to that URL, loads inside Iframe ), and when the processing payment returns successful, most of the time it completely reloads the parent page ( Returns url, plus POST data to the Successful URL, Reloads parent to that URL ) 然后returns back a POST data在大多数情况下,处理失败时,它不会重新加载父项( Return url, plus POST data to that URL, loads inside Iframe并将Return url, plus POST data to that URL, loads inside Iframe ),并且在处理付款成功返回后,通常会完全重新加载父页面(将Returns url, plus POST data to the Successful URL, Reloads parent to that URL将父页面Returns url, plus POST data to the Successful URL, Reloads parent to that URL

As this is code from the secure payment, there isn't alot of things I can show. 由于这是安全付款的代码,因此我无法显示很多东西。

Is there any javascript or Html attr that will make this without randomness 是否有任何javascript或HTML属性可以使它无randomness

End up using sandbox mode for iframe and forced stop the redirection atleast for modern browsers. 最终在iframe中使用沙盒模式,并在现代浏览器中至少停止了重定向。

sandbox="" without allow-top-navigation will force prevent the reload 没有allow-top-navigation sandbox=""将强制阻止重新加载

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/iframe

If it only redirects on successful attempts and not every time, then it is most likely redirected from the server (eg using a redirect header, or a window.refresh) then you would have to fix your code there (if you have control over it). 如果仅在成功尝试之后才重定向,而不是每次都重定向,则很可能是从服务器重定向的(例如,使用重定向头或window.refresh),那么您将不得不在那里修复代码(如果可以控制它) )。

If you don't have control over the server side code where the iframe is coming from, ask the owner of the API for help. 如果您无法控制iframe所在的服务器端代码,请向API所有者寻求帮助。 If they refuse (which they will most likely do) to apply the changes you need, it will probably be due to security concerns (if the user's transaction is getting processed on another server, why is the page hosted in an iframe in your page? read about click jacking ) 如果他们拒绝(他们很可能会这样做)应用所需的更改,则可能是由于安全方面的考虑(如果在另一台服务器上处理用户的交易,为什么页面托管在页面的iframe中?了解有关点击顶升的信息

Either way, I would use fiddler, or any other tool you can think of to examin the contents of a successful response to verify whether the server side code is redirecting. 无论哪种方式,我都会使用Fiddler或您可以想到的任何其他工具来检查成功响应的内容,以验证服务器端代码是否正在重定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM