खिड़की खुली ()
उदाहरण 1
एक नए ब्राउज़र टैब में "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: . |
प्रतिलाभ की मात्रा
नई विंडो का संदर्भ, या कॉल विफल होने पर अशक्त । |
और ज्यादा उदाहरण
एक नई विंडो/टैब में इसके बारे में: खाली पृष्ठ खोलें:
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/");
एक नई विंडो खोलें। नई विंडो बंद करने के लिए बंद करें () का उपयोग करें:
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
ब्राउज़र समर्थन
open()
सभी ब्राउज़रों में समर्थित है:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |