I'm trying to close a child window with JavaScript, and in Firefox everything works fine but in Chrome the window doesn't close.
Here is what I'm using
$(document).ready(function() { if (window.opener && !window.opener.closed) window.opener.location = "http://www.website.com" window.close(); });
I tried a suggestion on google, but to no avail.
Anyone having a similar issue or know of a work-around?
close() function won't work due to Chrome Security feature which not allow close the current window by JavaScript window. close(). If you check the message in the Chrome Developer Tool Console, you will find such message: Scripts may close only the windows that were opened by it.
First: Try these common Chrome crash fixesYour computer may have run out of memory, and can't load the site while also running your apps, extensions, and programs. To free up memory: Close every tab except for the one that's showing the error message. Quit other apps or programs that are running.
Click the 'Extensions' tab, locate 'Chrome Toolbox by Google,' and then click the 'Options' link under the description of the extension. Check the box next to 'Confirm Before Closing Multiple Tabs' in the 'Tabs' section to automatically update your browser's settings.
I know this question is old, but I ran into the same problem. This worked for me:
window.open('', '_self', ''); //bug fix window.close();
If previously you open some other window by window.open()
This don't work:
window.open(...) window.open('', '_self', ''); window.close();
But work:
window.open(...); setTimeout(function(){ window.open('', '_self', ''); window.close(); }, 100);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With