Skip to content

Commit f556148

Browse files
line 54
1 parent 8ffcf95 commit f556148

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

3-frames-and-windows/01-popup-windows/article.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
# Popups and window methods
1+
# Popups و window methods
22

3-
A popup window is one of the oldest methods to show additional document to user.
3+
یک popup window یکی از قدیمی‌ترین روش‌ها برای نشان دادن document اضافی به کاربر است.
44

5-
Basically, you just run:
5+
اساسا شما فقط اجرا می‌کنید:
66
```js
77
window.open('https://javascript.info/')
88
```
99

10-
...And it will open a new window with given URL. Most modern browsers are configured to open url in new tabs instead of separate windows.
10+
... و آن یک پنجره‌ی جدید با URL داده شده باز می‌کند. اکثر مرورگرهای مدرن به گونه‌ای پیکربندی شده‌اند که به جای پنجره‌های جداگانه، آدرس اینترنتی را در پنجره‌های جدید باز کنند.
1111

12-
Popups exist from really ancient times. The initial idea was to show another content without closing the main window. As of now, there are other ways to do that: we can load content dynamically with [fetch](info:fetch) and show it in a dynamically generated `<div>`. So, popups is not something we use everyday.
12+
از زمان‌های بسیار قدیم،‌ Popupها وجود دارند. ایده‌ی اولیه این بود که بتوان یک محتوای دیگر را بدون بستن پنجره‌ی اصلی نمایش داد. در حال حاضر، راه‌های دیگری برای این کار وجود دارد: می‌توانیم داده را به صورت پویا با [fetch](info:fetch) بارگیری کنیم و آن را در یک `<div>` که به صورت پویا ایجاد شده است نمایش دهیم. بنابراین، popupها چیزهایی نیستند که ما هر روز از آن‌ها استفاده کنیم.
1313

14-
Also, popups are tricky on mobile devices, that don't show multiple windows simultaneously.
14+
همچنین، popupها در دستگاه‌های موبایل که چند پنجره را به صورت همزمان نشان نمی‌دهند کمی مشکل هستند.
1515

16-
Still, there are tasks where popups are still used, e.g. for OAuth authorization (login with Google/Facebook/...), because:
16+
با این حال، کارهایی وجود دارند که popupها هنوز در آن‌ها استفاده می‌شوند. برای مثال، برای مجوز OAuth (lgin با Google/Facebook/...) چون که:
1717

18-
1. A popup is a separate window which has its own independent JavaScript environment. So opening a popup from a third-party, non-trusted site is safe.
19-
2. It's very easy to open a popup.
20-
3. A popup can navigate (change URL) and send messages to the opener window.
18+
1. یک popup پنجره‌ای جدا است که محیط JavaScript جداگانه‌ی خود را دارد. بنابراین باز کردن یک popup از یک سایت سوم غیر قابل اطمینان، امن است.
19+
2. باز کردن یک popup بسیار ساده است.
20+
3. یک popup می‌تواند پیمایش کند (آدرس سایت را تغییر دهد)‌ و به پنجره‌ی بازکننده پیام بفرستد.
2121

2222
## Popup blocking
2323

24-
In the past, evil sites abused popups a lot. A bad page could open tons of popup windows with ads. So now most browsers try to block popups and protect the user.
24+
در گذشته، سایت‌های خبیث بسیار از popup سواستفاده می‌کردند. یک صفحه می‌توانست تعداد زیادی popup با تبلیغات باز کند. بنابراین امروزه، اکثر مرورگرها تلاش می‌‌کنند که popup را مسدود کنند و از کاربر در برابر آن‌ها محافظت کنند.
2525

26-
**Most browsers block popups if they are called outside of user-triggered event handlers like `onclick`.**
26+
**اکثر مرورگرها، اگر فراخوانی popupها خارج از event handlerهای ایجاد شده توسط کاربر صورت بگیرد، آن‌ها را مسدود می‌کنند.**
2727

28-
For example:
28+
برای مثال:
2929
```js
30-
// popup blocked
30+
// popup مسدود شده است
3131
window.open('https://javascript.info');
3232

33-
// popup allowed
33+
// popup اجازه داده شده است
3434
button.onclick = () => {
3535
window.open('https://javascript.info');
3636
};
3737
```
3838

39-
This way users are somewhat protected from unwanted popups, but the functionality is not disabled totally.
39+
به این ترتیب، کاربرها تا حدودی از popupهای ناخواسته محافظت می‌شوند، اما عملکرد به طور کامل غیرفعال نمی‌شود.
4040

4141
## window.open
4242

43-
The syntax to open a popup is: `window.open(url, name, params)`:
43+
برای باز کردن یک popup از syntax روبه‌رو استفاده می‌شود: `window.open(url, name, params)`:
4444

4545
url
46-
: An URL to load into the new window.
46+
: یک URL برای بارگیری در پنجره جدید.
4747

4848
name
49-
: A name of the new window. Each window has a `window.name`, and here we can specify which window to use for the popup. If there's already a window with such name -- the given URL opens in it, otherwise a new window is opened.
49+
: یک name پنجره‌ی جدید. هر پنجره یک `window.name` دارد و اینجا می‌توانیم مشخص کنیم که از کدام پنجره به عنوان popup استفاده کنیم. اگر قبلا پنجره‌ای با این نام وجود داشته باشد، -- URL داده شده در آن باز می‌شود، در غیر این صورت، یک پنجره‌ی جدید باز می‌شود.
5050

5151
params
52-
: The configuration string for the new window. It contains settings, delimited by a comma. There must be no spaces in params, for instance: `width=200,height=100`.
52+
: رشته‌ی configuration برای پنجره‌ی جدید. این شامل تنظیماتی است که با comma مشخص می‌شوند. هیچ spaceای نباید در params وجود داشته باشد،‌ برای مثال: `width=200,height=100`
5353

54-
Settings for `params`:
54+
تنظیمات برای `params`:
5555

5656
- Position:
5757
- `left/top` (numeric) -- coordinates of the window top-left corner on the screen. There is a limitation: a new window cannot be positioned offscreen.

0 commit comments

Comments
 (0)