如何用JS打开新窗口,并关闭原来窗口
2个回答
展开全部
做一个触摸屏查询系统,要打开新页面后关闭父界面 百度之functionopenNewWindow() { window.open("Index.aspx","","left=30,top=30,toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,copyhistory=no,height=620,width=820"); window.opener=null; window.open("","_self"); window.close(); }
这样写的话,由于窗口拦截的原因,会使新窗口打不开,而且原来的窗口也被关闭了
于是再查询找到解决去方法在新页面中onload="window.opener。opener=null; window.opener.close();"
这样写的话,由于窗口拦截的原因,会使新窗口打不开,而且原来的窗口也被关闭了
于是再查询找到解决去方法在新页面中onload="window.opener。opener=null; window.opener.close();"
展开全部
我来把格式怎规范点:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function openNewWindow() {
window.open("forwardnewpage.jsp","","left=30,top=30,height=620,width=820,toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,copyhistory=no");
window.opener=null;
window.open("","_self");
window.close();
}
</script>
</head>
<body>
<input type="button" value="打开新窗口关闭旧的" onclick="openNewWindow()">
</body>
</html>
新窗口页面代码(如果浏览器允许弹窗可以不要onload这段代码):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>new page</title>
</head>
<body onload="window.opener.opener=null; window.opener.close();">
<table border="1" cellpadding="1" cellspacing="0" align="center" style="text-align: center;">
<caption>表格标题</caption>
<tr>
<th>标题1</th>
<th>标题2</th>
<th>标题3</th>
</tr>
<tr>
<td>测试</td>
<td>测试</td>
<td>测试</td>
</tr>
<tr>
<td>测试</td>
<td>测试</td>
<td>测试</td>
</tr>
</table>
<br>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function openNewWindow() {
window.open("forwardnewpage.jsp","","left=30,top=30,height=620,width=820,toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,copyhistory=no");
window.opener=null;
window.open("","_self");
window.close();
}
</script>
</head>
<body>
<input type="button" value="打开新窗口关闭旧的" onclick="openNewWindow()">
</body>
</html>
新窗口页面代码(如果浏览器允许弹窗可以不要onload这段代码):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>new page</title>
</head>
<body onload="window.opener.opener=null; window.opener.close();">
<table border="1" cellpadding="1" cellspacing="0" align="center" style="text-align: center;">
<caption>表格标题</caption>
<tr>
<th>标题1</th>
<th>标题2</th>
<th>标题3</th>
</tr>
<tr>
<td>测试</td>
<td>测试</td>
<td>测试</td>
</tr>
<tr>
<td>测试</td>
<td>测试</td>
<td>测试</td>
</tr>
</table>
<br>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询