diff --git a/3-frames-and-windows/01-popup-windows/article.md b/3-frames-and-windows/01-popup-windows/article.md index 5fc87a2e3..ce67d9b9c 100644 --- a/3-frames-and-windows/01-popup-windows/article.md +++ b/3-frames-and-windows/01-popup-windows/article.md @@ -13,6 +13,7 @@ Les pop-up existent depuis longtemps. L'idée initiale était de montrer du cont Les pop-up sont également délicate sur les appareils mobiles puis que ces derniers ne peuvent pas afficher plusieurs fenêtres simultanément. + Pourtant, il y a quelques tâches où les pop-up sont toujours utilisées, par exemple pour les authentifications OAuth (se connecter avec Google/Facebook..) pour les raisons suivantes : 1. Une pop-up est une fenêtre séparée avec son environnement JavaScript indépendant. Donc ouvrir une pop-up d'une tierce partie venant d'un site peu fiable est sécurisé. 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..3cb81b02a 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 +# Communication entre les fenêtres -The "Same Origin" (same site) policy limits access of windows and frames to each other. +La politique "Same Origin" (même site) limite l'accès des fenêtres et des iframe les uns aux autres. -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'idée est que si un utilisateur a deux pages ouvertes : une de `john-smith.com`, et une autre de `gmail.com`, alors il ne voudra pas d'un script de `john-smith.com` pour lire son courrier de `gmail.com`. L'objectif de la politique "Same origin" est donc de protéger les utilisateurs contre le vol d'informations. ## Same Origin [#same-origin] -Two URLs are said to have the "same origin" if they have the same protocol, domain and port. +Deux URLs sont dites de "Same origin" si elles ont le mêmes protocole, domaine et port. -These URLs all share the same origin: +Ces URLs partagent toutes la même origine ("Same origin"): - `http://site.com` - `http://site.com/` - `http://site.com/my/page.html` -These ones do not: +Ce n'est pas le cas de celles ci: -- 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 (différent domaine: `www.` importe) +- http://site.org (différent domaine: `.org` importe) +- https://site.com (différent protocole: `https`) +- http://site.com:8080 (différent port: `8080`) -The "Same Origin" policy states that: +La politique "Same Origin" indique que: -- 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: +Le code ci-dessus indique les erreurs pour toutes les opérations sauf: -- Getting the reference to the inner window `iframe.contentWindow` - that's allowed. -- Writing to `location`. +- Obtenir la référence de la fenêtre intérieure `iframe.contentWindow` - c'est autorisé. +- Ecrire dans `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,93 +186,94 @@ For instance: ``` -An iframe may have other iframes inside. The corresponding `window` objects form a hierarchy. +Une iframe peut contenir d'autres iframes. Les objets `window` correspondants forment une hiérarchie. -Navigation links are: +Les liens de navigation sont: -- `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 collection de fenêtres "enfants" (pour les cadres emboîtés). +- `window.parent` -- la référence à la fenêtre "parent" (extérieure). +- `window.top` -- la référence à la fenêtre parentale la plus élevée. -For instance: +Par exemple: ```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: +Nous pouvons utiliser la propriété `top` pour vérifier si le document actuel est ouvert à l'intérieur d'un cadre ou non: ```js run -if (window == top) { // current window == window.top? +if (window == top) { // fenêtre actuelle == 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'attribut iframe "sandbox" -The `sandbox` attribute allows for the exclusion of certain actions inside an `