最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to close a parent window? - Stack Overflow

programmeradmin3浏览0评论

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.

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

When I use this code,

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(); is working for IE and Chrome but in Mozilla it shows the error:

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

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

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.

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

When I use this code,

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(); is working for IE and Chrome but in Mozilla it shows the error:

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

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

Share Improve this question edited Aug 31, 2015 at 10:10 asked Aug 24, 2015 at 12:57 user4961104user4961104
Add a ment  | 

2 Answers 2

Reset to default 2

Why are you using that way? Just use:

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

Or, you can use:

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

If you are using script in HTML wrap it with tag like:

Please click <a  onclick="CloseWindow();" href="#">here</a> to close this window.
<script type="text/javascript">
   function CloseWindow() {
      window.parent.close();
   }
</script>
发布评论

评论列表(0)

  1. 暂无评论