首页 > 技术文章 > BOM操作

guniang 2019-07-11 10:48 原文

bom中常见的方法

  setTimeout(fn,时间) 延迟方法

  setInterval(fn,时间)  定时器,一般制作动画用

  location.href() 打开一个新页面

  location.reload() 重载页面

  window.open("地址","_self | _blank  | _parent")

 

设置两秒后跳转地址

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>bom操作</title>
</head>
<body>
<a href="#">bom操作</a>
<script>
    setTimeout(function () {
        indow.location.href = 'http://www.apeland.cn'
    },2000);
window.location.href = 'http://www.apeland.cn'
</script>
</body>
</html>


localtion.reload 加载页面,但是一般不推荐使用
window.open("www.baidu.com",'_self') 打开网页,在当前页面打开

history.go(0); 表示刷新
history.go(1); 表示前进
history.go(-1); 表示后退

 

推荐阅读