BOM_window属性和Location
BOM_window属性
属性:
1、获取其他BOM对象:
history:对 History 对象的只读引用。
location:用于窗口或框架的 Location 对象
Navigator:对 Navigator 对象的只读引用
Screen:对 Screen 对象的只读引用
2、获取DOM对象
document:对 Document 对象的只读引用
//获取history var h1 = window.history; var h2 = history; alert(h1) alert(h2) var openid = window.document.getElementById("openBtn"); alert(openid);
BOM_Location
Location:地址栏对象
1、创建(获取)
1、window.location
2、location
2、方法
reload():重新加载当前文档
3、属性
href:设置或返回完整的URL
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <input type="button" id="btn" value="刷新"> <input type="button" id="go" value="bd"> <script> //reload方法:定义一个按钮,点击按钮,刷新当前页面 //获取按钮 var btn = document.getElementById("btn"); //绑定单击事件 btn.onclick = function () { //刷新页面 location.reload(); } //获取href var href = location.href; // alert(href); //点击按钮,访问页面 var go = document.getElementById("go"); go.onclick = function () { location.href = "http://www.baidu.com"; } </script> </body> </html>

浙公网安备 33010602011771号