js 開啟新頁面
阿新 • • 發佈:2019-02-07
經常會遇到在js中開啟新頁面或者新視窗的問題,現整理最近使用的幾種方法:【直接複製就可以執行】
<html> <head> <title>開啟新視窗</title> <SCRIPT> //開啟新視窗全屏 function ow(owurl){ var tmp=window.open("about:blank","","fullscreen=1") tmp.moveTo(0,0) tmp.resizeTo(screen.width+20,screen.height) tmp.focus() tmp.location=owurl } function WinOpen() { window.open("http://www.baidu.com","DisplayWindow","toolbar=no,,menubar=no,location=no,scrollbars=no"); } //網頁訊息對話方塊 function openModelessDialog(){ var features='status:0;dialogWidth:470px;dialogHeight:270px;resizable:0;scroll:0;center:1'; showModelessDialog("http://www.baidu.com",window,features); } //網頁對話方塊,一次只能開啟一個 function openModalDialog(){ var features='status:0;dialogWidth:470px;dialogHeight:270px;resizable:0;scroll:0;center:1'; showModalDialog("http://www.baidu.com",window,features); } //子視窗開啟,關閉父視窗 function openChild(){ window.open('http://www.baidu.com/','','width=790,height=590'); window.opener=null; window.close(); } </SCRIPT> </head> <body> <button onclick="javascript:ow('http://www.baidu.com')">開啟新視窗全屏</button><br> <button onclick="WinOpen()">正常開啟一個彈出視窗</button><br> <button onclick="openModelessDialog()">網頁對話方塊[開啟多個]</button><br> <button onclick="openModalDialog()">網頁對話方塊[開啟一個]</button><br> <button onclick="openChild()">子視窗開啟,關閉父視窗</button><br> </body> </html>