window.open 可開啟新視窗或新分頁,常用於彈出視窗。可設定寬高、工具列、網址列、捲軸等。
window.open(url, "_blank", "height=200,width=400,toolbar=no,menubar=no");
showModalDialog 可開啟強制互動的對話框,在舊版 IE 常見。可設定 dialogHeight、dialogWidth、center、status、scroll 等。
window.showModalDialog(url, null, "dialogHeight:300px;dialogWidth:850px;center:yes;");
現代瀏覽器多限制非使用者觸發的彈出視窗,showModalDialog 也已不建議使用。新專案可考慮 dialog 元素或自訂遮罩層。