用window.location和window.open做链接的区别
关键字:window.location window.open()
在给按钮、表格、单元格、下拉列表和DIV等做链接时一般都要用Javascript来完成,和做普通链接一样,可能我们需要让链接页面在当前窗口打开,也可能需要在新窗口打开,这时我们就可以使用下面两项之一来完成:
window.open 用来打开新窗口
window.location 用来替换当前页,也就是重新定位当前页
window.location 用来替换当前页,也就是重新定位当前页
我们可以用以下来个实例来测试一下。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>引导页面</title>
</script>
</head>
<body>
<input type="button" value="新窗口打开" οnclick="window.open('http://www.hao123.com')">
<input type="button" value="当前页打开" οnclick="window.location='http://www.163.com'">
</body>
</html>