BOM_Window_属性
属性:(Window调用)
获取其他BOM对象:
history
location
Navigator
Screen
获取DOM对象
document
//获取history var h1 = window.history; var h2 = history; alert(h1); alert(h2); let elementById = document.getElementById("openBId"); alert(elementById);
BOM_Location
Location:地址栏对象
创建(获取):
window.location
location
方法:
reload():重新载入当前文档 刷新
属性:
href 返回完整的URL
<body> <input type="button" value="刷新" id="btn"> <input type="button" value="郭伟明老婆" id="bn"> <script> /* Location:地址栏对象 创建(获取): window.location location 方法: reload():重新载入当前文档 刷新 属性: href 返回完整的URL */ //1.获取按钮 let btn = document.getElementById("btn"); //2.绑定点击事件 btn.onclick = function fun(){ //3.刷新页面 location.reload(); } //获取按钮 var href = location.href; // alert(href); let bn = document.getElementById("bn"); //绑定单击事件 bn.onclick = function fun() { //访问官网 location.href = "https://cn.bing.com/images/search?q=%e7%be%8e%e5%a5%b3&qpvt=%e7%be%8e%e5%a5%b3&form=IGRE&first=1&tsc=ImageHoverTitle"; } </script> </body>
标签:BOM,获取,Window,href,location,Location From: https://www.cnblogs.com/qihaokuan/p/16903655.html