[英]How to close iframe window on reload page with javascript
I have website in PHP.And my situation is that I have checkout page that I need to click on submit button for payment process in iframe window. 我有PHP网站,我的情况是我有结帐页面,我需要在iframe窗口中单击提交按钮进行付款过程。 After complete payment process, I need to close iframe window and redirect to success page.But iframe did not close and page redirected into iframe.
完成付款过程后,我需要关闭iframe窗口并重定向到成功页面。但是iframe没有关闭,页面已重定向到iframe。
Code look like this: 代码如下:
<form><input type="button" name="payfort" value="Continue" onclick="CreditPay();" id="payfort" class="payfort" /></form>
<script type="text/javascript">
function CreditPay() {
var pop = document.getElementById('popup-win');
pop.style.display = 'block';
document.getElementById('overlay').className = 'show';
document.getElementById('payfortForm').submit();
return false;
}</script>
And below code is open in iframe: 下面的代码在iframe中打开:
<div class="popup-win" id="popup-win" style="display: none;">
<div class="popup-header">
</div>
<div class="popup-subtitle">
Transaction Value:<span class='currency-txt'>AED 17.00</span>
</div>
<iframe id="ifrmPAYFORT" name="ifrmPAYFORT" style="width: 100%; height: 450px"></iframe></div>
<div class="overlay" id="overlay"></div>
<form METHOD="post" ACTION="http://localhost/phppayfort/success.php" id="payfortForm" name="payfortForm" target="ifrmPAYFORT">
<input type="hidden" name="service_command" value="<?php echo $requestParams['service_command'] ?>">
<input type="hidden" name="language" value="<?php echo $requestParams['language'] ?>">
<input type="hidden" name="merchant_identifier" value="<?php echo $requestParams['merchant_identifier'] ?>">
<input type="hidden" name="access_code" value="<?php echo $requestParams['access_code'] ?>">
<input type="hidden" name="signature" value="<?php echo $signature ?>">
<input type="hidden" name="return_url" value="<?php echo $requestParams['return_url'] ?>">
<input type="hidden" name="merchant_reference" value="<?php echo $requestParams['merchant_reference'] ?>">
</form>
So, is there any way to close iframe window on reload page? 那么,有什么方法可以关闭重新加载页面上的iframe窗口吗?
Many thanks in advance for recommendations. 在此先非常感谢您的建议。
You can set a class for your iframe, like: 您可以为iframe设置一个类,例如:
<iframe class="myiframe"></iframe>
And play with some JS, when form submited, update class="myiframe" and add 'display: none;'. 并在提交表单时使用一些JS,更新class =“ myiframe”并添加'display:none;'。
For redirection, you can use href.location 对于重定向,可以使用href.location
How to hide your iframe: 如何隐藏您的iframe:
iframeToHide = document.getElementsByClassName("myiframe");
iframeToHide.style.display = "none";
How to redirect: 如何重定向:
window.location = "http://www.yoururl.com";
Note, this is a JS solution, with PHP I don't know if you will be able to solve this. 注意,这是一个JS解决方案,使用PHP我不知道您是否能够解决这个问题。
Cheers! 干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.