导读:(1)页面间直接跳转window.location.href='http://www.bcty365.com/list-9-1.html';具体用法如:<input type="button" onClick=...
(1)页面间直接跳转
window.location.href='http://www.bcty365.com/list-9-1.html';
具体用法如:
<input type="button" onClick="location.href='http://www.bcty365.com/list-100-1.html" />
由这个衍生出来的方法还有好几个,比如:
window.navigate('跳转页面URL地址');//注意window.navigate(sURL)方法是针对IE的,不适用于FF,在HTML DOM Window Object中,根本没有列出window.navigate这个方法。所以这个方法基本不用考虑了。
self.location='跳转页面URL地址';
top.location='跳转页面URL地址';//主要用于框架内部的某个页面跳转
(2)新窗口打开页面
window.open('http://www.bcty365.com/list-12-1.html');
具体用法如:
<input type="button" onClick="window.open('http://www.bcty365.com/list-61-1.html')" />
注意 window.open 这个动作的参数特别多,可以配合各种参数来控制新开窗口的特征。比如新开窗口的高,宽,窗口大小是否可调整等等。这里就不一一解释了,需要了解的朋友可以去搜索引擎里面去搜。
(3)返回上一页
window.history.back(-1);
具体用法如:
<a href="javascript:history.go(-1)">返回上一页</a>
(4)页面定时自动跳转的js代码(下面这个例子的意思是3秒自动将页面跳转到http://www.phpernote.com/php-function/463.html这个页面)
查看代码打印
1
<script language="javascript" type="text/javascript">
2
setTimeout("javascript:location.href='http://www.bcty365.com/list-86-1.html'",3000);
3
</script>
(5)head标签内加如下代码实现页面定时自动跳转
<meta http-equiv="refresh" content="5;url=http://www.bcty365.com/list-96-1.html" />
上面这句代码的意思是5秒钟之后页面将自动跳转到 http://www.bcty365.com/list-96-1.html 这个页面,虽然这个已经不属于js跳转代码了,但是也是一种页面跳转方法,注意这段代码需要加在 head 标签内。