You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -65,7 +64,7 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
65
64
let href =iframe.contentWindow.location.href; // ERROR
66
65
*/!*
67
66
} catch(e) {
68
-
alert(e); //Security Error
67
+
alert(e); //خطای امنیتی
69
68
}
70
69
71
70
// ... !(بارگذاری کنیم iframe و در نتیجه چیز دیگری را) بنویسیم location ما میتوانیم بر
@@ -74,15 +73,14 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
74
73
*/!*
75
74
76
75
iframe.onload=null; // آن را اجرا کند location را پاک میکند، نه اینکه بعد از تغییر handler این
77
-
78
76
};
79
77
</script>
80
78
```
81
79
82
80
کد بالا خطاهای هر عملیاتی را نشان میهد به جز:
83
81
84
82
- گرفتن ارجاع به پنجرهی درونی `iframe.contentWindow` - آن مجاز است.
85
-
- نوشتن برا`location`
83
+
- نوشتن بر`location`
86
84
87
85
بر خلاف آن، اگر `<iframe>` منبع یکسانی داشته باشد، ما میتوانیم با آن هر کاری بکنیم:
88
86
@@ -104,21 +102,21 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
104
102
...اما نمیتوانیم به `iframe.contentWindow.onload` برای یک iframe از مبدا دیگری دسترسی پیدا کنیم،بنابراین از `iframe.onload` استفاده میکنیم.
105
103
```
106
104
107
-
## Windows on subdomains: document.domain
105
+
## پنجرهها در زیردامنهها: document.domain
108
106
109
-
By definition, two URLs with different domains have different origins.
107
+
طبق تعریف، دو URL با دامنههای مختلف، منشأ متفاوتی دارند.
110
108
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" برای اهداف ارتباط بین پنجرهای در نظر گرفت.
112
110
113
-
To make it work, each such window should run the code:
111
+
برای اینکه کار کند، هر پنجره باید کد زیر را اجرا کند:
114
112
115
113
```js
116
114
document.domain = 'site.com';
117
115
```
118
116
119
-
That's all. Now they can interact without limitations. Again, that's only possible for pages with the same second-level domain.
117
+
همهاش همین است. حالا آنها میتوانند بدون محدودیت با هم تعامل داشته باشند. باز هم، این فقط برای صفحاتی با همان دامنهی سطح دوم امکان پذیر است.
120
118
121
-
```warn header="Deprecated, but still working"
119
+
```warn header="منسوخ شده، اما همچنان کار میکند"
122
120
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.
123
121
124
122
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