20180723- JavaScript-Bom对象-location对象

 

 

 

 

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
       .box1{height:400px;background:#ccc;}
       .box2{height:600px;background:#666;}
	</style>
</head>
<body>
	<div class="box1" id="top"></div>
	<div class="box2"></div>
	<input type="button" id="btn" value="返回顶部">
	<script>
       //console.log(location.href);
       //console.log(location.hash);
       var btn=document.getElementById("btn");
       btn.onclick=function(){
          location.hash="#top";
       }
       console.log(location.pathname);
	</script>
</body>
</html>

 

学习目标

 

 

 

 

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<input type="button" value="刷新" id="reload">
	<script>
      /*  setTimeout(function(){
            //location.href='index6.html';
            // window.location='index6.html';
            location.replace("index6.html");
        },1000)*/
         document.getElementById("reload").onclick=function(){
         	 location.reload(true);
         }
	</script>
</body>
</html>

 

history对象

 

 

 

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<div class="box">
		请输入搜索关键字:
		<input type="text" placeholder="请输入搜索关键字" id="key">
		<input type="button" value="搜索" id="search">
	</div>
	<a href="#" id="go">跳转</a>
	<script>
       // 给按钮绑定事件
       document.getElementById("search").onclick=function(){
       	  // 获取搜索关键字并对它进行编码
       	  var key=encodeURIComponent(document.getElementById("key").value);
       	  // 跳转到指定页面
       	  location.href='index9.html?search_key='+key;
       }
       var sea="搜索";
       document.getElementById("go").href='index.html?key='+encodeURI(sea);
	</script>
</body>
</html>

 

forward

 

 

 

 

Navigator对象

 

 

 

 

 

Screen

 

 

 

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>screen</title>
</head>
<body>
	<script>
        console.log("页面宽:"+screen.availWidth);
        console.log("页面高:"+screen.availHeight);

        console.log("pageWidth:"+window.innerWidth);
        console.log("pageHeight:"+window.innerHeight);
	</script>
</body>
</html>

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值