Skip to content

Commit 4ac9431

Browse files
line 119 remove extra lines
1 parent 54a8d6a commit 4ac9431

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

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

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
For instance, let's try reading and writing to `<iframe>` from another origin:
4141
برای مثال، بیایید تلاش کنیم خواندن و نوشتن بر `<iframe>` از یک منبع دیگر را امتحان کنیم.
42-
4342
```html run
4443
<iframe src="https://example.com" id="iframe"></iframe>
4544

@@ -65,7 +64,7 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
6564
let href = iframe.contentWindow.location.href; // ERROR
6665
*/!*
6766
} catch(e) {
68-
alert(e); // Security Error
67+
alert(e); // خطای امنیتی
6968
}
7069
7170
// ... !(بارگذاری کنیم iframe و در نتیجه چیز دیگری را) بنویسیم location ما می‌توانیم بر
@@ -74,15 +73,14 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
7473
*/!*
7574
7675
iframe.onload = null; // آن را اجرا کند location را پاک می‌کند، نه اینکه بعد از تغییر handler این
77-
7876
};
7977
</script>
8078
```
8179

8280
کد بالا خطاهای هر عملیاتی را نشان می‌هد به جز:
8381

8482
- گرفتن ارجاع به پنجره‌ی درونی `iframe.contentWindow` - آن مجاز است.
85-
- نوشتن برا `location`
83+
- نوشتن بر `location`
8684

8785
بر خلاف آن، اگر `<iframe>` منبع یکسانی داشته باشد،‌ ما می‌توانیم با آن هر کاری بکنیم:
8886

@@ -104,21 +102,21 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
104102
...اما نمی‌توانیم به `iframe.contentWindow.onload` برای یک iframe از مبدا دیگری دسترسی پیدا کنیم،‌بنابراین از `iframe.onload` استفاده می‌کنیم.
105103
```
106104
107-
## Windows on subdomains: document.domain
105+
## پنجره‌ها در زیردامنه‌ها: document.domain
108106
109-
By definition, two URLs with different domains have different origins.
107+
طبق تعریف، دو URL با دامنه‌های مختلف، منشأ متفاوتی دارند.
110108
111-
But if windows share the same second-level domain, for instance `john.site.com`, `peter.site.com` and `site.com` (so that their common second-level domain is `site.com`), we can make the browser ignore that difference, so that they can be treated as coming from the "same origin" for the purposes of cross-window communication.
109+
اما اگر پنجره‌ها دامنه‌ی سطح دوم یکسانی داشته باشند، برای مثال `john.site.com`، `peter.site.com` و `site.com` (به طوری که دامنه‌ی سطح دوم مشترک آن‌ها `site.com` باشد) ما می‌توانیم مرورگر را مجبور کنیم این تفاوت را نادیده بگیرد، به طوری که می‌توان آن‌ها را به عنوان "same origin" برای اهداف ارتباط بین پنجره‌ای در نظر گرفت.
112110
113-
To make it work, each such window should run the code:
111+
برای اینکه کار کند، هر پنجره باید کد زیر را اجرا کند:
114112
115113
```js
116114
document.domain = 'site.com';
117115
```
118116

119-
That's all. Now they can interact without limitations. Again, that's only possible for pages with the same second-level domain.
117+
همه‌اش همین است. حالا آن‌ها می‌توانند بدون محدودیت با هم تعامل داشته باشند. باز هم، این فقط برای صفحاتی با همان دامنه‌ی سطح دوم امکان پذیر است.
120118

121-
```warn header="Deprecated, but still working"
119+
```warn header="منسوخ شده، اما همچنان کار می‌کند"
122120
The `document.domain` property is in the process of being removed from the [specification](https://html.spec.whatwg.org/multipage/origin.html#relaxing-the-same-origin-restriction). The cross-window messaging (explained soon below) is the suggested replacement.
123121
124122
That said, as of now all browsers support it. And the support will be kept for the future, not to break old code that relies on `document.domain`.

0 commit comments

Comments
 (0)