Skip to content

Commit 16d04d6

Browse files
committed
WIP: translate - popup-windows
1 parent e5b0fc1 commit 16d04d6

1 file changed

Lines changed: 40 additions & 42 deletions

File tree

4-frames-and-windows/01-popup-windows/article.md

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,82 @@
1-
# Popups and window methods
1+
# ポップアップとウィンドウメソッド
22

3-
A popup window is one of the oldest methods to show additional document to user.
3+
ポップアップウィンドウは、利用者に追加のコンテンツを見せるための最も古い方法の1つです。
44

5-
Basically, you just run:
5+
基本的には次のように実行するだけです:
66
```js
77
window.open('http://javascript.info/')
88
```
99

10-
... And it will open a new window with given URL. Most modern browsers are configured to open new tabs instead of separate windows.
10+
... すると、指定された URL で新しいウィンドウが開きます。ほとんどのモダンブラウザは、別ウィンドウではなく新しいタブとして開くよう設定されています。
1111

12-
[cut]
12+
## ポップアップブロック
1313

14-
## Popup blocking
14+
ポップアップはとても古くから存在します。当初の考えは、メインのウィンドウを閉じることなく別のコンテンツを表示することでした。現時点では、それをするための他の方法があります: JavaScript はサーバへリクエストを送ることができるので、ポップアップはめったに使われません。しかし、それでも依然として便利なときはあります。
1515

16-
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.
16+
過去、悪意のあるサイトはポップアップを大いに乱用しました。悪意のあるページは広告を含むウィンドウを何度も開く事ができました。そのため、現在多くのブラウザはポップアップをブロックし、ユーザを守ろうとしています。
1717

18-
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.
18+
**ほとんどのブラウザは、`onclick` などユーザがトリガーしたイベントハンドラ外から呼ばれた場合には、ポップアップをブロックします。**
1919

20-
**Most browsers block popups if they are called outside of user-triggered event handlers like `onclick`.**
20+
これについて考える場合、少し注意が必要です。もしコードが直接 `onclick` 内にあればそれは簡単です。しかし、ポップアップは `setTimeout` で開くでしょうか?
2121

22-
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`?
23-
24-
Try this code:
22+
このコードを試してみましょう:
2523

2624
```js run
27-
// open after 3 seconds
25+
// 3秒後に開く
2826
setTimeout(() => window.open('http://google.com'), 3000);
2927
```
3028

31-
The popup opens in Chrome, but gets blocked in Firefox.
29+
Chrome ではポップアップは開きますが、Firefox ではブロックされます。
3230

33-
...And this works in Firefox too:
31+
...そして、これは Firefox でも機能します。:
3432

3533
```js run
36-
// open after 1 seconds
34+
// 1秒後に開く
3735
setTimeout(() => window.open('http://google.com'), 1000);
3836
```
3937

40-
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.
38+
違いは、Firefox 2000ms 以下のタイムアウトは許容することです。しかし、その後は "信頼" がなくなり、"ユーザ操作の範囲外" であると想定します。そのため、最初のはブロックされ、2つ目は開きました。
4139

42-
## Modern usage
40+
## モダンな使用方法
4341

44-
As of now, we have many methods to load and show data on-page with JavaScript. But there are still situations when a popup works best.
42+
現在、JavaScriptを使用してデータをロードし、ページ上に表示する方法は数多くあります。しかし、ポップアップがベストな選択肢である状況はまだあります。
4543

46-
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.
44+
例えば、多くのお店は相談にのる方法としてオンラインチャットを使います。訪問者がボタンを押すと、`window.open` が実行され、チャットをするポップアップが開きます。
4745

48-
Why a popup is good here, why not in-page?
46+
なぜ、ここではページ内ではなくポップアップが良いのでしょう?
4947

50-
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.
48+
1. ポップアップは独立した JavaScript 環境を持つ別ウィンドウです。なので、チャットサービスはメインの店舗サイトのスクリプトと統合する必要がありません。
49+
2. ポップアップはサイトに追加するのが非常に簡単で、オーバーヘッドがほとんどありません。スクリプトの追加は不要で小さいボタンだけです。
50+
3. ポップアップは利用者がページを離れても持続させることができます。例えば、相談で利用者に新しい "スーパークーラー" のページを訪れるようにアドバイスします。利用者はメインウィンドウでそのページへ行きますが、チャットは無くなりません。
5351

5452
## window.open
5553

56-
The syntax to open a popup is: `window.open(url, name, params)`:
54+
ポップアップを開く構文は次の通りです: `window.open(url, name, params)`:
5755

5856
url
59-
: An URL to load into the new window.
57+
: 新しいウィンドウでロードする URL
6058

6159
name
62-
: 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.
60+
: 新しいウィンドウの名前。各ウィンドウは `window.name` を持っており、ここでポップアップに使うウィンドウを指定することができます。すでに同じ名前のウィンドウがあった場合、そこで指定された URL が開きます。なければ新しいウィンドウが開きます。
6361

6462
params
65-
: 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`.
63+
: 新しいウィンドウの設定文字列。カンマで区切られた設定を含みます。params の中にスペースを入れてはいけません。例: `width:200,height=100`.
6664

67-
Settings for `params`:
65+
`params` の設定:
6866

69-
- Position:
70-
- `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.
67+
- ポジション:
68+
- `left/top` (数値) -- 画面上のウィンドウの左上隅の座標。新しいウィンドウを画面外に配置することはできない、という制限があります。
69+
- `width/height` (数値) -- 新しいウィンドウの width height 。 最小の width/height の制限があるので、, 見えないウィンドウを作成することはできません。
70+
- ウィンドウの機能:
71+
- `menubar` (yes/no) -- 新しいウィンドウで、ブラウザのメニューを表示します/非表示にします。
72+
- `toolbar` (yes/no) -- 新しいウィンドウで、ブラウザナビゲーション(戻る/進む/更新など)を表示します/非表示にします。
73+
- `location` (yes/no) -- 新しいウィンドウで、URL フィールドを表示します/非表示にします。FF IE はデフォルトでは隠すことは許可されていません。
74+
- `status` (yes/no) -- ステータスバーを表示します/非表示にします。ほとんどのブラウザは強制的に表示させます。
75+
- `resizable` (yes/no) -- 新しいウィンドウのリサイズを無効にします。非推奨です。
76+
- `scrollbars` (yes/no) -- 新しいウィンドウのスクロールバーを無効にします。非推奨です。
7977

8078

81-
There is also a number of less supported browser-specific features, which are usually not used. Check <a href="https://developer.mozilla.org/en/DOM/window.open">window.open in MDN</a> for examples.
79+
あまりサポートされていないブラウザ固有の機能も数多くありますが、通常は使用されていません。例については、<a href="https://developer.mozilla.org/en/DOM/window.open">window.open in MDN</a> を確認してみてください。
8280

8381
## Example: a minimalistic window
8482

@@ -178,7 +176,7 @@ Still, there are some things that can be done.
178176
For instance:
179177

180178
- 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.
182180

183181
## Summary
184182

@@ -190,4 +188,4 @@ For instance:
190188
- Methods `focus()` and `blur()` allow to focus/unfocus a window. Sometimes.
191189
- 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`.
192190

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

Comments
 (0)