如何用javascript关闭重新加载页面的iframe窗口
How to close iframe window on reload page with javascript
我在PHP网站。我的情况是,我有结帐页面,我需要点击提交按钮在iframe窗口的支付过程。完成支付过程后,我需要关闭iframe窗口并重定向到成功页面。但是iframe没有关闭,页面重定向到iframe。
代码如下:
<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>
下面的代码在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>
所以,有没有办法关闭iframe窗口重新加载页面?
非常感谢您的推荐。
您可以为iframe设置一个类,如:
<iframe class="myiframe"></iframe>
并且玩一些JS,当表单提交时,更新class="myiframe"并添加'display: none;'.
对于重定向,您可以使用href.location 如何隐藏iframe:iframeToHide = document.getElementsByClassName("myiframe");
iframeToHide.style.display = "none";
如何重定向:
window.location = "http://www.yoururl.com";
注意,这是一个JS解决方案,用PHP我不知道你是否能解决这个问题。
干杯!
相关文章:
- Chrome扩展:加载窗口后执行脚本
- 在IE7中加载窗口
- jQuery加载窗口,同时等待长函数完成
- 如何在加载时将加载窗口添加到 sencha 中的图表
- 想要在加载窗口上计算字符数
- 如何在加载窗口后加载图像
- 弹出加载窗口
- 防止在重新加载窗口时看到选项卡
- 加载窗口时采取措施
- Don'如果href有#,则不希望加载窗口
- 使用Javascript,如何在单击下载文件的链接后1秒重新加载窗口
- 加载窗口大小问题
- 提交后弹出.显示加载窗口或请等待
- 我应该从哪里调用警报框,加载窗口-控制器或服务
- 如果内容是动态的,如何在打开窗口后重新加载窗口
- 在iframe内加载窗口
- 执行jquery函数后,图像已加载窗口调整大小
- 通过X按钮和加载窗口事件关闭弹出窗口
- IE和JavaScript:调整大小时重新加载窗口
- 单击后可以加载窗口吗