ပြတင်းပေါက်ဖွင့်ခြင်း()
ဥပမာ ၁
ဘရောက်ဆာတက်ဘ်အသစ်တွင် "www.w3schools.com" ကိုဖွင့်ပါ။
window.open("https://www.w3schools.com");
အောက်တွင် နောက်ထပ် ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် open()
သင့်ဘရောက်ဆာဆက်တင်များနှင့် ပါရာမီတာတန်ဖိုးများပေါ်မူတည်၍ ဘရောက်ဆာဝင်းဒိုးအသစ် သို့မဟုတ် တက်ဘ်အသစ်တစ်ခုဖွင့်သည်။
ကိုလည်းကြည့်ပါ-
အထားအသို
window.open(URL, name, specs, replace)
ကန့်သတ်ချက်များ
Parameter | Description | ||||||||||||||||||||||||
URL | Optional. The URL of the page to open. If no URL is specified, a new blank window/tab is opened |
||||||||||||||||||||||||
name | Optional. The target attribute or the name of the window. The following values are supported: | ||||||||||||||||||||||||
|
|||||||||||||||||||||||||
specs | Optional. A comma-separated list of items, no whitespaces. The following values are supported: | ||||||||||||||||||||||||
| |||||||||||||||||||||||||
replace |
DeprecatedSpecifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:
WarningChrome throws an exception when using this parameter. Source: . |
တန်ဖိုးကို ပြန်ပေးသည်။
ခေါ်ဆိုမှု မအောင်မြင်ပါက ဝင်းဒိုးအသစ်ကို ရည်ညွှန်းခြင်း သို့မဟုတ် null |
နောက်ထပ် ဥပမာများ
ဝင်းဒိုး/တက်ဘ်အသစ်တွင် about:blank စာမျက်နှာကိုဖွင့်ပါ-
var myWindow = window.open("", "", "width=200,height=100");
"MsgWindow" ဟုခေါ်သော ဝင်းဒိုးအသစ်ကိုဖွင့်ပြီး ၎င်းတွင် စာသားအချို့ရေးပါ။
var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");
လက်ရှိဝင်းဒိုးကို ဝင်းဒိုးအသစ်ဖြင့် အစားထိုးပါ။
var myWindow = window.open("", "_self");
myWindow.document.write("<p>I replaced the current window.</p>");
ဝင်းဒိုးအသစ်တစ်ခုဖွင့်ပြီး ၎င်း၏အသွင်အပြင်ကို ထိန်းချုပ်ပါ-
window.open("https://www.w3schools.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
တက်ဘ်များစွာကို ဖွင့်ပါ-
window.open("http://www.google.com/");
window.open("https://www.w3schools.com/");
ဝင်းဒိုးအသစ်တစ်ခုဖွင့်ပါ။ ဝင်းဒိုးအသစ်ကိုပိတ်ရန် close() ကိုသုံးပါ။
function openWin() {
myWindow = window.open("", "myWindow", "width=200,height=100"); // Opens a new window
}
function closeWin() {
myWindow.close(); // Closes the new window
}
ဝင်းဒိုးအသစ်တစ်ခုဖွင့်ပါ။ ဝင်းဒိုးအသစ်၏အမည်ကို ပြန်ပေးရန်အတွက် အမည်ပိုင်ဆိုင်မှုကို အသုံးပြုပါ-
var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This window's name is: " + myWindow.name + "</p>");
ဝင်းဒိုးအသစ်ကို ဖန်တီးထားသည့် ဝင်းဒိုးကို ရည်ညွှန်းချက်ပြန်ပေးရန် အဖွင့်ပစ္စည်းပိုင်ဆိုင်မှုကို အသုံးပြုခြင်း-
var myWindow = window.open("", "myWindow", "width=200,height=100"); // Opens a new window
myWindow.document.write("<p>This is 'myWindow'</p>"); // Text in the new window
myWindow.opener.document.write("<p>This is the source window!</p>"); // Text in the window that created the new window
Browser ပံ့ပိုးမှု
open()
ဘရောက်ဆာအားလုံးတွင် ထောက်ခံသည်-
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |