如何关闭父窗口? [英] how to close a parent window?

查看:161
本文介绍了如何关闭父窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提交表单时,我有一个申请表单,该表单将重定向到具有打印"并关闭选项的窗口.

I have a application form when I submit the form it is redirecting to window which have options "print" and close.

Please click <a  onclick="self.close();" href="#">here</a> to close this window.

如果我单击关闭,则选项卡本身在chrome和IE中关闭,但在Mozilla中不起作用.

If I click on close,the tab itself closing in chrome and IE but it not working in Mozilla.

当我使用此代码时,

Please click <a  onclick="CloseWindow();" href="#">here</a> to close this window.

<script type="text/javascript">

    function CloseWindow() {
         open(location, '_parent').close()
    }
</script>

它正在重定向以应用在线页面.

it is redirecting to apply online page.

我将如何关闭选项卡本身.

How I will close the tab itself.

self.close();适用于IE和Chrome,但在Mozilla中显示错误:

self.close(); is working for IE and Chrome but in Mozilla it shows the error:

脚本可能无法关闭脚本未打开的窗口.

Scripts may not close windows that were not opened by script.

或者我们可以使'dom.allow_scripts_to_close_windows,true;'使用c#或javascript?

Or can we make ' dom.allow_scripts_to_close_windows, true;' using c# or javascript?

推荐答案

您为什么使用这种方式?只需使用:

Why are you using that way? Just use:

function CloseWindow() {
  window.parent.close();
}

或者,您可以使用:

function CloseWindow() {
  window.close();
}

这篇关于如何关闭父窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆