diff --git a/3-frames-and-windows/03-cross-window-communication/article.md b/3-frames-and-windows/03-cross-window-communication/article.md index 091a0cecb..e9d92c5b3 100644 --- a/3-frames-and-windows/03-cross-window-communication/article.md +++ b/3-frames-and-windows/03-cross-window-communication/article.md @@ -1,130 +1,130 @@ -# Cross-window communication +# Міжвіконна комунікація -The "Same Origin" (same site) policy limits access of windows and frames to each other. +Політика "Одного походження" (Same Origin), іншими словами один й той самий сайт, вона обмежує доступ вікон і фреймів один до одного. -The idea is that if a user has two pages open: one from `john-smith.com`, and another one is `gmail.com`, then they wouldn't want a script from `john-smith.com` to read our mail from `gmail.com`. So, the purpose of the "Same Origin" policy is to protect users from information theft. +Ідея полягає в тому, що якщо користувач має дві відкриті сторінки: одну з `john-smith.com`, а іншу -- `gmail.com`, тоді він не хоче, щоб скрипт з `john-smith.com` читав пошту з `gmail.com`. Отже, мета політики "Одного походження" -- захистити користувачів від крадіжки даних. -## Same Origin [#same-origin] +## Політика "Одного походження" (Same Origin) [#same-origin] -Two URLs are said to have the "same origin" if they have the same protocol, domain and port. +Кажуть, що дві URL-адреси мають "одне походження", якщо вони мають однаковий протокол, домен і порт. -These URLs all share the same origin: +Усі ці URL-адреси мають одне походження: - `http://site.com` - `http://site.com/` - `http://site.com/my/page.html` -These ones do not: +А ці ні: -- http://www.site.com (another domain: `www.` matters) -- http://site.org (another domain: `.org` matters) -- https://site.com (another protocol: `https`) -- http://site.com:8080 (another port: `8080`) +- http://www.site.com (інший домен: `www.` має значення) +- http://site.org (інший домен: `.org` має значення) +- https://site.com (інший протокол: `https`) +- http://site.com:8080 (інший порт: `8080`) -The "Same Origin" policy states that: +У політиці "Одного походження" зазначено, що: -- if we have a reference to another window, e.g. a popup created by `window.open` or a window inside ` ``` -The code above shows errors for any operations except: +Код вище показує помилки для будь-яких операцій, крім: -- Getting the reference to the inner window `iframe.contentWindow` - that's allowed. -- Writing to `location`. +- Отримання посилання на внутрішнє вікно `iframe.contentWindow` -- це дозволено. +- Зміни `location`. -Contrary to that, if the ` ``` ```smart header="`iframe.onload` vs `iframe.contentWindow.onload`" -The `iframe.onload` event (on the ` @@ -156,26 +156,26 @@ We can try to catch the moment earlier using checks in `setInterval`: ``` -## Collection: window.frames +## Колекція: window.frames -An alternative way to get a window object for ` @@ -186,93 +186,93 @@ For instance: ``` -An iframe may have other iframes inside. The corresponding `window` objects form a hierarchy. +Усередині iframe можуть бути інші iframe. Відповідні об’єкти `window` утворюють ієрархію. -Navigation links are: +Навігаційні посилання: -- `window.frames` -- the collection of "children" windows (for nested frames). -- `window.parent` -- the reference to the "parent" (outer) window. -- `window.top` -- the reference to the topmost parent window. +- `window.frames` -- колекція дочірніх вікон (для вкладених фреймів). +- `window.parent` -- посилання на "батьківське" (зовнішнє) вікно. +- `window.top` -- посилання на найвище батьківське вікно. -For instance: +Наприклад: ```js run window.frames[0].parent === window; // true ``` -We can use the `top` property to check if the current document is open inside a frame or not: +Ми можемо використовувати властивість `top`, щоб перевірити, чи відкритий поточний документ у фреймі чи ні: ```js run if (window == top) { // current window == window.top? - alert('The script is in the topmost window, not in a frame'); + alert('Скрипт знаходиться у батьківському вікні, а не у фреймі'); } else { - alert('The script runs in a frame!'); + alert('Скрипт виконується у фреймі!'); } ``` -## The "sandbox" iframe attribute +## Атрибут iframe "sandbox" -The `sandbox` attribute allows for the exclusion of certain actions inside an ` diff --git a/3-frames-and-windows/03-cross-window-communication/sandbox.view/index.html b/3-frames-and-windows/03-cross-window-communication/sandbox.view/index.html index 46dd7b5cc..f3cfd1789 100644 --- a/3-frames-and-windows/03-cross-window-communication/sandbox.view/index.html +++ b/3-frames-and-windows/03-cross-window-communication/sandbox.view/index.html @@ -7,7 +7,7 @@ -
The iframe below has the sandbox attribute.
+
Наведений нижче iframe має атрибут sandbox.
diff --git a/3-frames-and-windows/03-cross-window-communication/sandbox.view/sandboxed.html b/3-frames-and-windows/03-cross-window-communication/sandbox.view/sandboxed.html index c10273255..93793f9c1 100644 --- a/3-frames-and-windows/03-cross-window-communication/sandbox.view/sandboxed.html +++ b/3-frames-and-windows/03-cross-window-communication/sandbox.view/sandboxed.html @@ -7,11 +7,11 @@ - +
- +