HTML页⾯⾃动跳转,windows操作1) html的实现
<head>
<!-- 以下⽅式只是刷新不跳转到其他页⾯ -->
<meta http-equiv="refresh" content="10">
<!-- 以下⽅式定时转到其他页⾯ -->
<meta http-equiv="refresh" content="5;url=hello.html">
</head>
2) javascript的实现
<script language="javascript" type="text/javascript">
// 以下⽅式直接跳转
window.location.href='hello.html';
/
/ 打开新的页⾯
window.open(url)
// 以下⽅式定时跳转
setTimeout("javascript:location.href='hello.html'", 5000);
</script>
<span id="totalSecond">5</span>
<script language="javascript" type="text/javascript">
var second = totalSecond.innerText;
setInterval("redirect()", 1000);
function redirect(){
totalSecond.innerText=--second;
if(second<0) location.href='hello.html';
}
</script>
其他
(0)
load()
3 location=location
4 location.assign(location)
Command('Refresh')
6 window.navigate(location)
place(location)
8 document.URL=location.href
这⼏个都可以刷新
load();刷新
window.location.href=window.location.href;刷新
window.close();关闭窗⼝,不弹出系统提⽰,直接关闭
window.close()相当于self属性是当前窗⼝
window.parent.close()是parent属性是当前窗⼝或框架的框架组
页⾯实现跳转的九种⽅法实例:
<html>
< head>
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
< title>navigate</title>
< script language="javascript">
setTimeout('window.navigate("top.html");',2000);
setTimeout('window.document.location.href="top.html";',2000);
setTimeout('window.document.location="top.html";',2000);
setTimeout('window.location.href="top.html";',2000);
setTimeout('window.location="top.html";',2000);
setTimeout('document.location.href="top.html";',2000);pdf转html
setTimeout('document.location="top.html";',2000);
setTimeout('location.href="top.html";',2000);
setTimeout('place("top.html")',2000);
/
/window对象
//document对象
//location对象
//href属性
//1.window.document.location.href
//2.window.document.location
//3.window.location.href
//4.window.location
//5.document.location.href
//6.document.location
//7.location.href
/
/8.window.navigate
//place
//只要使⽤location⽅法,和任意的window对象,location对象,href属性连⽤,都可以页⾯的跳转////
< /script>
< /head>
< body>
页⾯将在2秒后跳转
< /body>
< /html>
解释:
location是个对象,⽐如本页的document.location和window.location的属性有
location.hostname = community.csdn
location.href = community.csdn/Expert/topic/l?temp=2.695864E-02 location.host = community.csdn
location.hash =
location.port =
location.pathname = /Expert/topic/l
location.search = ?temp=2.695864E-02
location.protocol = http:
可见href是location的属性,类别是string。
发布评论