Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q308 When using window.close() some pages ask 'Close Window? (yes/no)' and others don't, why?

You are here: irt.org | FAQ | JavaScript | Window | Q308 [ previous next ]

Its a security thing. It'll work without asking if there is only one location in the browsers history, if theres more than one, it prompts the user for confirmation. If this becomes a problem, you can always restrict the history of a window to one location by using the replace() method, for those browsers that support it.

If the window was opened from Javascript (like window.open() method), while closing those windows, user will not be prompted. Where as if the window was opened self, like (Target='-blank' etc), while closing those windows, user will be prompted.

Feedback on 'Q308 When using window.close() some pages ask 'Close Window? (yes/no)' and others don't, why?'

©2018 Martin Webb