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 aa9d1cab4..a7294df68 100644 --- a/3-frames-and-windows/03-cross-window-communication/article.md +++ b/3-frames-and-windows/03-cross-window-communication/article.md @@ -1,88 +1,88 @@ -# 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`، آنگاه آن‌ها نمی‌خواهند که که یک script از `john-smith.com` تمام نامه‌‌های شما از `gmail.com` را بخواند. بنابراین، هدف سیاست "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ها یک protocol، domain و ports داشته باشند، می‌گویند که "same origin" دارند. -These URLs all share the same origin: +این لینک‌ها همگی یک منبع را به اشتراک می‌گذارند. - `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`) -The "Same Origin" policy states that: +سیاست "Same Origin" بیان می‌کند که: -- 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 ` @@ -163,26 +163,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 ` @@ -193,93 +193,93 @@ For instance: ``` -An iframe may have other iframes inside. The corresponding `window` objects form a hierarchy. +یک فریم ممکن است فریم‌های دیگری هم درون خود داشته باشد. اشیای `پنجره‌ی` مربوطه یک سلسله مراتب را تشکیل می‌دهند. -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` property استفاده کنیم که چک کنیم که document جاری درون یک فریم باز است یا نه: ```js run -if (window == top) { // current window == window.top? - alert('The script is in the topmost window, not in a frame'); +if (window == top) { // جاری window == window.top? + alert('در بالاترین پنجره است، نه در یک فریم script'); } else { - alert('The script runs in a frame!'); + alert('!در یک فریم اجرا می‌شود script'); } ``` -## The "sandbox" iframe attribute +## "sandbox" iframe attribute -The `sandbox` attribute allows for the exclusion of certain actions inside an `