You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Popups exist from really ancient times. The initial idea was to show another content without closing the main window. As of now, there are other ways to do that: JavaScript is able to send requests for server, so popups are rarely used. But sometimes they are still handy.
In the past evil sites abused popups a lot. A bad page could open tons of popup windows with ads. So now most browsers try to block popups and protect the user.
If you think about it, that's a bit tricky. If the code is directly in an `onclick` handler, then that's easy. But what is the popup opens in `setTimeout`?
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". So the first one is blocked, and the second one is not.
For instance, many shops use online chats for consulting people. A visitor clicks on the button, it runs `window.open`and opens the popup with the chat.
1.A popup is a separate window with its own independent JavaScript environment. So a chat service doesn't need to integrate with scripts of the main shop site.
51
-
2.A popup is very simple to attach to a site, little to no overhead. It's only a small button, without additional scripts.
52
-
3.A popup may persist even if the user left the page. For example, a consult advices the user to visit the page of a new "Super-Cooler" goodie. The user goes there in the main window without leaving the chat.
: A name of the new window. Each window has a `window.name`, and here we can specify which window to use for the popup. If there's already a window with such name -- the given URL opens in it, otherwise a new window is opened.
: The configuration string for the new window. It contains settings, delimited by a comma. There must be no spaces in params, for instance: `width:200,height=100`.
-`left/top` (numeric) -- coordinates of the window top-left corner on the screen. There is a limitation: a new window cannot be positioned offscreen.
71
-
-`width/height` (numeric) -- width and height of a new window. There is a limit on minimal width/height, so it's impossible to create an invisible window.
72
-
-Window features:
73
-
-`menubar` (yes/no) -- shows or hides the browser menu on the new window.
74
-
-`toolbar` (yes/no) -- shows or hides the browser navigation bar (back, forward, reload etc) on the new window.
75
-
-`location` (yes/no) -- shows or hides the URL field in the new window. FF and IE don't allow to hide it by default.
76
-
-`status` (yes/no) -- shows or hides the status bar. Again, most browsers force it to show.
77
-
-`resizable` (yes/no) -- allows to disable the resize for the new window. Not recommended.
78
-
-`scrollbars` (yes/no) -- allows to disable the scrollbars for the new window. Not recommended.
There is also a number of less supported browser-specific features, which are usually not used. Check <ahref="https://developer.mozilla.org/en/DOM/window.open">window.open in MDN</a> for examples.
79
+
あまりサポートされていないブラウザ固有の機能も数多くありますが、通常は使用されていません。例については、<ahref="https://developer.mozilla.org/en/DOM/window.open">window.open in MDN</a> を確認してみてください。
82
80
83
81
## Example: a minimalistic window
84
82
@@ -178,7 +176,7 @@ Still, there are some things that can be done.
178
176
For instance:
179
177
180
178
- When we open a popup, it's might be a good idea to run a `newWindow.focus()` on it. Just in case, for some OS/browser combinations it ensures that the user is in the new window now.
181
-
- If we want to track when a visitor actually uses our web-app, we can track `window.onfocus/onblur`. That allows us to suspend/resume in-page activities, animations etc. But please note that the `blur` event means that the visitor switched out from the window, but he still may observe it. The window is in the background, but still may be visible.
179
+
- If we want to track when a visitor actually uses our web-app, we can track `window.onfocus/onblur`. That allows us to suspend/resume in-page activities, animations etc. But please note that the `blur` event means that the visitor switched out from the window, but they still may observe it. The window is in the background, but still may be visible.
182
180
183
181
## Summary
184
182
@@ -190,4 +188,4 @@ For instance:
190
188
- Methods `focus()` and `blur()` allow to focus/unfocus a window. Sometimes.
191
189
- Events `focus` and `blur` allow to track switching in and out of the window. But please note that a window may still be visible even in the background state, after `blur`.
192
190
193
-
Also if we open a popup, a good practice is to notify the user about it. An icon with the opening window can help the visitor to survive the focus shift and keep both windows in mind.
191
+
Also if we open a popup, a good practice is to notify the user about it. An icon with the opening window can help the visitor to survive the focus shift and keep both windows in mind.
0 commit comments