
If we don’t need a popup any more, we can call newWindow.close() on it. If that’s not so, then there are still means to communicate, to be covered in the next chapter Cross-window communication. They may modify each other freely assuming that they come from the same origin. So both the main window and the popup have a reference to each other.
JAVASCRIPT POPUP WINDOW WINDOWS
It is null for all windows except popups. A JavaScript in it may use window.opener to access the window that opened it. Accessing the opener windowĪ popup may access the “opener” window as well. That’s for user safety, so that an evil page can’t open a popup with and read the data. Please note that external document content is only accessible for windows from the same origin (the same protocol://domain:port).įor windows with URLs from another sites, we are able to change the location by assigning newWindow.location=., but we can’t read the location or access the content. Let’s open a window with minimal set of features just to see which of them browser allows to disable: There is also a number of less supported browser-specific features, which are usually not used. scrollbars (yes/no) – allows to disable the scrollbars for the new window.resizable (yes/no) – allows to disable the resize for the new window.status (yes/no) – shows or hides the status bar.FF and IE don’t allow to hide it by default. location (yes/no) – shows or hides the URL field in the new window.toolbar (yes/no) – shows or hides the browser navigation bar (back, forward, reload etc) on the new window.menubar (yes/no) – shows or hides the browser menu on the new window.

There is a limit on minimal width/height, so it’s impossible to create an invisible window.


In also can navigate (change URL) in the opener window. A popup may persist even if the user left the page.It’s very easy to open a popup, little to no overhead.So opening a popup with a third-party non-trusted site is safe. A popup is a separate window with its own independent JavaScript environment.But there are still situations when a popup works good, because: Modern usageĪs of now, we have many methods to load and show data on-page with JavaScript. So the first one is blocked, and the second one is not. The difference is that Firefox treats a timeout of 2000ms or less are acceptable, but after it – removes the “trust”, assuming that now it’s “outside of the user action”.
