Everyone knows that window.close() is used to close windows, and both ie and firefox are supported.
In order to achieve the absolute control of the browser by users, when closing a non-open window in ie, a dialog box pops up when closing a non-open window, asking the user, how to remove this box, please see the code below.
function winClose(){ window.top.opener = null; window.close(); }Just add window.top.opener = null before window.close.
Some people say that firefox does not support close, but this is actually wrong. The reason why window.close cannot be used in firefox is because firefox cannot close the web page opened by users by default. You can set firefox in this way.
Open firefox and enter about:config in the address bar
Find the dom.allow_scripts_to_close_windows item and change it to true.
It should be said that there is no trouble with popping up dialog boxes in firefox.
<script>function a(){window.open('','_parent','');window.opener = window;window.close(); }</script>Run this again and you can close it under ff.
Seeing these, if the customer is asked to set them up, it means that this function is not done, so the result is not very satisfactory, and I don’t know if there are other good alternatives.
Postscript: Use the opening of a new window and then closing this page to close the current page. Thanks strangebank. But strangely, I didn't succeed when I used ff2 yesterday, but today I succeeded with 3. It's really a hell. Today I used 2 on my colleague's machine to test it, and it's OK again. But it's good to solve the problem early in the morning. ^_^
index.html
<a href="c.html" target="_blank">ddddddddd</a>
c.html
<a href="javascript:window.open('','_parent','');window.close();">Close Window</a>