javascriptjqueryasp.netmozilla

how to close a parent window?


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?


Solution

  • Why are you using that way? Just use:

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

    Or, you can use:

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