Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript cross browser window close issue

I have this code here:

<?php
    error_reporting(0);
    if(isset($_GET['bd'])){
?>

<script>
    window.close();
</script>


<?php

}

Which is working okay in Chrome, but not working in FireFox. Is there a known issue with this? How can I get it to work consistently across the mentioned browsers?

like image 819
choppermio Avatar asked Mar 17 '26 07:03

choppermio


1 Answers

In most browsers, window.close() will only work if the window in question has an opener. By an opener, I mean that you have a parent window that opens a child window. Only the child window can be closed by a window.close().

like image 170
Gabe Avatar answered Mar 19 '26 20:03

Gabe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!