JS Reference

JS by Category JS by Alphabet

JavaScript

JS Array JS Boolean JS Classes JS Date JS Error JS Global JS JSON JS Math JS Number JS Operators JS RegExp JS Statements JS String

Window

Window Object Window Console Window History Window Location Window Navigator Window Screen

HTML DOM

DOM Document DOM Element DOM Attributes DOM Events DOM Event Objects DOM HTMLCollection DOM Style
alignContent alignItems alignSelf animation animationDelay animationDirection animationDuration animationFillMode animationIterationCount animationName animationTimingFunction animationPlayState background backgroundAttachment backgroundColor backgroundImage backgroundPosition backgroundRepeat backgroundClip backgroundOrigin backgroundSize backfaceVisibility border borderBottom borderBottomColor borderBottomLeftRadius borderBottomRightRadius borderBottomStyle borderBottomWidth borderCollapse borderColor borderImage borderImageOutset borderImageRepeat borderImageSlice borderImageSource borderImageWidth borderLeft borderLeftColor borderLeftStyle borderLeftWidth borderRadius borderRight borderRightColor borderRightStyle borderRightWidth borderSpacing borderStyle borderTop borderTopColor borderTopLeftRadius borderTopRightRadius borderTopStyle borderTopWidth borderWidth bottom boxShadow boxSizing captionSide caretColor clear clip color columnCount columnFill columnGap columnRule columnRuleColor columnRuleStyle columnRuleWidth columns columnSpan columnWidth counterIncrement counterReset cursor direction display emptyCells filter flex flexBasis flexDirection flexFlow flexGrow flexShrink flexWrap cssFloat font fontFamily fontSize fontStyle fontVariant fontWeight fontSizeAdjust height isolation justifyContent left letterSpacing lineHeight listStyle listStyleImage listStylePosition listStyleType margin marginBottom marginLeft marginRight marginTop maxHeight maxWidth minHeight minWidth objectFit objectPosition opacity order orphans outline outlineColor outlineOffset outlineStyle outlineWidth overflow overflowX overflowY padding paddingBottom paddingLeft paddingRight paddingTop pageBreakAfter pageBreakBefore pageBreakInside perspective perspectiveOrigin position quotes resize right scrollBehavior tableLayout tabSize textAlign textAlignLast textDecoration textDecorationColor textDecorationLine textDecorationStyle textIndent textOverflow textShadow textTransform top transform transformOrigin transformStyle transition transitionProperty transitionDuration transitionTimingFunction transitionDelay unicodeBidi userSelect verticalAlign visibility width wordBreak wordSpacing wordWrap widows zIndex

Web APIs

API Console API Fullscreen API Geolocation API History API MediaQueryList API Storage

HTML Objects

<a> <abbr> <address> <area> <article> <aside> <audio> <b> <base> <bdo> <blockquote> <body> <br> <button> <canvas> <caption> <cite> <code> <col> <colgroup> <datalist> <dd> <del> <details> <dfn> <dialog> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <footer> <form> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <ins> <input> button <input> checkbox <input> color <input> date <input> datetime <input> datetime-local <input> email <input> file <input> hidden <input> image <input> month <input> number <input> password <input> radio <input> range <input> reset <input> search <input> submit <input> text <input> time <input> url <input> week <kbd> <label> <legend> <li> <link> <map> <mark> <menu> <menuitem> <meta> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <s> <samp> <script> <section> <select> <small> <source> <span> <strong> <style> <sub> <summary> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <textarea> <time> <title> <track> <u> <ul> <var> <video>

Other References

CSSStyleDeclaration JS Conversion


Jendela terbuka()

Contoh 1

Buka "www.w3schools.com" di tab browser baru:

window.open("https://www.w3schools.com");

Lebih banyak contoh di bawah ini.


Definisi dan Penggunaan

Metode open()ini membuka jendela browser baru, atau tab baru, tergantung pada pengaturan browser Anda dan nilai parameter.

Lihat juga:

Metode tutup() .


Sintaksis

window.open(URL, name, specs, replace)

Parameter

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:
ValueDescription
_blankURL is loaded into a new window, or tab. This is the default
_parentURL is loaded into the parent frame
_selfURL replaces the current page
_topURL replaces any framesets that may be loaded
nameThe name of the window (does not specify the title of the window)
specs Optional.
A comma-separated list of items, no whitespaces.
The following values are supported:
fullscreen=yes|no|1|0 Whether or not to display the browser in full-screen mode. Default is no. A window in full-screen mode must also be in theater mode. IE only
height=pixels The height of the window. Min. value is 100
left=pixels The left position of the window. Negative values not allowed
location=yes|no|1|0 Whether or not to display the address field. Opera only
menubar=yes|no|1|0 Whether or not to display the menu bar
resizable=yes|no|1|0 Whether or not the window is resizable. IE only
scrollbars=yes|no|1|0 Whether or not to display scroll bars. IE, Firefox & Opera only
status=yes|no|1|0 Whether or not to add a status bar
titlebar=yes|no|1|0 Whether or not to display the title bar. Ignored unless the calling application is an HTML Application or a trusted dialog box
toolbar=yes|no|1|0 Whether or not to display the browser toolbar. IE and Firefox only
top=pixels The top position of the window. Negative values not allowed
width=pixels The width of the window. Min. value is 100
replace

Deprecated

Specifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:
  • true - URL replaces the current document in the history list
  • false - URL creates a new entry in the history list

Warning

Chrome throws an exception when using this parameter.

Source: .

Nilai Kembali

Referensi ke jendela baru, atau null jika panggilan gagal.


Lebih Banyak Contoh

Buka halaman about:blank di jendela/tab baru:

var myWindow = window.open("", "", "width=200,height=100");

Buka jendela baru bernama "MsgWindow", dan tulis beberapa teks ke dalamnya:

var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");

Ganti jendela saat ini dengan jendela baru:

var myWindow = window.open("", "_self");
myWindow.document.write("<p>I replaced the current window.</p>");

Buka jendela baru dan kendalikan tampilannya:

window.open("https://www.w3schools.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");

Buka banyak tab:

window.open("http://www.google.com/");
window.open("https://www.w3schools.com/");

Buka jendela baru. Gunakan close() untuk menutup jendela baru:

function openWin() {
  myWindow = window.open("", "myWindow", "width=200,height=100");   // Opens a new window
}

function closeWin() {
  myWindow.close();   // Closes the new window
}

Buka jendela baru. Gunakan properti nama untuk mengembalikan nama jendela baru:

var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This window's name is: " + myWindow.name + "</p>");

Menggunakan properti pembuka untuk mengembalikan referensi ke jendela yang membuat jendela baru:

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

Dukungan Peramban

open()didukung di semua browser:

Chrome IE Edge Firefox Safari Opera
Yes Yes Yes Yes Yes Yes