js 打开新页面

经常会遇到在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>

 更多文章见:http://www.16boke.com

你可能感兴趣的:(js 打开新页面)