From 5f61e529536a2721cf33a83a868791d57bc79f8e Mon Sep 17 00:00:00 2001 From: Andrea Longo Date: Wed, 24 Mar 2021 22:07:36 +0100 Subject: [PATCH 1/7] translated first part --- .../03-cross-window-communication/article.md | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) 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..4f53c79b9 100644 --- a/3-frames-and-windows/03-cross-window-communication/article.md +++ b/3-frames-and-windows/03-cross-window-communication/article.md @@ -1,65 +1,65 @@ -# Cross-window communication +# Comuniaczione cross-window -The "Same Origin" (same site) policy limits access of windows and frames to each other. +La politcia di "Same Origin" ("stessa origine", ovvero stesso sito) limita il reciproco accesso tra finestre ed iframe diversi. -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. +L'idea è che, se un utente ha deu pagine aperte: una su `john-smith.com`, ed un'altra su `gmail.com`, allora non vorrà che uno script ion esecuzione su `john-smith.com` possa leggere tutte le sue mail dalla finestra di `gmail.com`. Quindi, lo scopo della politica "Same Origin" è quello di proteggere l'utente dal furto di informazioni. ## Same Origin [#same-origin] -Two URLs are said to have the "same origin" if they have the same protocol, domain and port. +Due URL vengono definiti come appartenenti alla "stessa origine" solo se possiedono lo stesso protocollo, dominio e porta. -These URLs all share the same origin: +Ad esempio, questi URL condividono la stessa origine: - `http://site.com` - `http://site.com/` - `http://site.com/my/page.html` -These ones do not: +Questi invece no: -- 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 (dominio differente: `www.` è diverso) +- http://site.org (dominio differente: `.org` è diverso) +- https://site.com (protocollo differente: `https`) +- http://site.com:8080 (porta differente: `8080`) -The "Same Origin" policy states that: +La politica di "Same Origin" afferma che: -- 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: +Il codice sopra genera errori in tutti i casi ad eccezione di: -- Getting the reference to the inner window `iframe.contentWindow` - that's allowed. -- Writing to `location`. +- Lettura del riferimento alla finestra interna `iframe.contentWindow`, la quale è permessa. +- Scrittura su `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 -An alternative way to get a window object for ` @@ -186,31 +186,31 @@ For instance: ``` -An iframe may have other iframes inside. The corresponding `window` objects form a hierarchy. +Un iframe potrebbe possedere a sua volta degli iframe. I rispettivi oggetti `window` formeranno una gerarchia. -Navigation links are: +E' possibile navigare tra le finestre della gerarchia utilizzando: -- `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`: la collezione delle finestre "figlie" (per iframe annidati). +- `window.parent`: il riferimento alla finestra "padre" (quella esterna). +- `window.top`: il riferiemento alla finestra in cima alla gerarchia. -For instance: +Ad esempio: ```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: +Possiamo utilizzare la proprietà `top` per verificare se il document corrente è aperto all'interno di un iframe o no: ```js run -if (window == top) { // current window == window.top? +if (window == top) { // window == window.top? alert('The script is in the topmost window, not in a frame'); } else { alert('The script runs in a frame!'); } ``` -## The "sandbox" iframe attribute +## L'attributo "sandbox" per iframe The `sandbox` attribute allows for the exclusion of certain actions inside an `