Skip to content

Commit 181832e

Browse files
line 41
1 parent 426c598 commit 181832e

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

  • 3-frames-and-windows/03-cross-window-communication

3-frames-and-windows/03-cross-window-communication/article.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
1-
# Cross-window communication
1+
# ارتباط بین پنجره‌ای
22

3-
The "Same Origin" (same site) policy limits access of windows and frames to each other.
3+
سیاست "Same Origin" (همان سایت) دسترسی پنجره‌ها و فریم‌ها به یکدیگر را محدود می‌کند.
44

5-
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.
5+
ایده این است که اگر یک یک کاربر دو صفحه‌ی باز داشته باشد: یکی از `john-smith.com` و دیگری از `gmail.com`، آنگاه آن‌ها نمی‌خواهند که که یک script از `john-smith.com` تمام نامه‌‌های شما از `gmail.com` را بخواند. بنابراین، هدف سیاست "Same Origin" این است که کاربران را از دزدی اطلاعات حفظ کند.
66

77
## Same Origin [#same-origin]
88

9-
Two URLs are said to have the "same origin" if they have the same protocol, domain and port.
9+
اگر URLها یک protocol، domain و ports داشته باشند، می‌گویند که "same origin" دارند.
1010

11-
These URLs all share the same origin:
11+
این URLها همگی یک منبع را به اشتراک می‌گذارند.
1212

1313
- `http://site.com`
1414
- `http://site.com/`
1515
- `http://site.com/my/page.html`
1616

17-
These ones do not:
17+
این یکی‌ها نه:
1818

1919
- <code>http://<b>www.</b>site.com</code> (another domain: `www.` matters)
2020
- <code>http://<b>site.org</b></code> (another domain: `.org` matters)
2121
- <code><b>https://</b>site.com</code> (another protocol: `https`)
2222
- <code>http://site.com:<b>8080</b></code> (another port: `8080`)
2323

24-
The "Same Origin" policy states that:
24+
سیاست "Same Origin" بیان می‌کند که:
2525

26-
- if we have a reference to another window, e.g. a popup created by `window.open` or a window inside `<iframe>`, and that window comes from the same origin, then we have full access to that window.
27-
- otherwise, if it comes from another origin, then we can't access the content of that window: variables, document, anything. The only exception is `location`: we can change it (thus redirecting the user). But we can't not *read* location (so we can't see where the user is now, no information leak).
26+
- اگر ما ارجاعی به پنجره‌ای دیگر داشته باشیم، برای مثال یک popup که با `window.open` ایجاد شده یا یک پنجره داخل `<iframe>`، و آن پنجره از منبع یکسان بیاید،‌آنگاه ما به آن پنجره دسترسی کامل داریم.
27+
- ذر غیر این صورت اگر از یک منبع دیگر بیاید،‌ آنگاه نمی‌توانیم به محتوای آن صفحه دسترسی داشته باشیم: متغیرها، document، هر چیزی. تنها استثنا `location` است: ما می‌توانیم آن را تغییر دهیم. (در نتیجه کاربر را هدایت کنیم). اما نمی‌توانیم از location *بخوانیم* (در نتیجه نمی‌توانیم ببینیم که کاربر در حال حاضر کجا است،‌ هیچ نشت اطلاعاتی وجود ندارد).
2828

29-
### In action: iframe
29+
### در عمل: iframe
3030

31-
An `<iframe>` tag hosts a separate embedded window, with its own separate `document` and `window` objects.
31+
یک تگ `<iframe>` میزبان یک پنجره‌ی جاسازی‌شده‌ی جداگانه با `document` جداگانه‌ی خود و اشیای `window` است.
3232

33-
We can access them using properties:
33+
می‌توان با استفاده از property‌ها به آن‌ها دسترسی داشت:
3434

35-
- `iframe.contentWindow` to get the window inside the `<iframe>`.
36-
- `iframe.contentDocument` to get the document inside the `<iframe>`, shorthand for `iframe.contentWindow.document`.
35+
- برای گرفتن پنجره‌ی داخل `<iframe>` از `iframe.contentWindow` استفاده می‌شود.
36+
- برای گرفتن documdnt داخل `<iframe>` از `iframe.contentDocument` استفاده می‌شود، کوتاه‌شده‌ی `iframe.contentWindow.document`.
3737

38-
When we access something inside the embedded window, the browser checks if the iframe has the same origin. If that's not so then the access is denied (writing to `location` is an exception, it's still permitted).
38+
وقتی به چیزی داخل پنجره‌ی جاسازی شده دسترسی پیدا می‌کنیم، مرورگر چک می‌کند که آیا iframe همان منبع را دارد یا نه. اگر اینطور نباشد،‌ دسترسی رد می‌شود (نوشتن بر `location` یک استثنا است،‌ آن همچنان مجاز است).
3939

4040
For instance, let's try reading and writing to `<iframe>` from another origin:
41+
برای مثال، بیایید تلاش کنیم خواندن و نوشتن بر `<iframe>` از یک منبع دیگر را امتحان کنیم.
4142

4243
```html run
4344
<iframe src="https://example.com" id="iframe"></iframe>

0 commit comments

Comments
 (0)