location对象
浏览器的地址栏对象
//对象中的属性和方法//location对象//console.log(window.location);//地址栏上#及后面的内容//console.log(window.location.hash);//主机名及端口号//console.log(window.location.host);//主机名//console.log(window.location.hostname);//文件的路径---相对路径//onsole.log(window.location.pathname);////端口号//console.log(window.location.port);//协议//console.log(window.location.protocol);//搜索的内容//onsole.log(window.location.search);
location其他的属性和方法
<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>Title</title></head><body><input type="button" id="btn" value="按钮"/><script> ???document.getElementById("btn").onclick = function () { ???????location.href="http://www.baidu.com";//跳转到页面的属性,浏览器有后退 ???????//location.assign("http://www.baidu.com");//跳转到页面的方法,浏览器有后退 ???????// location.reload();//重新加载--刷新 ???????//location.replace("http://www.jd.com");//替换,浏览器不能后退 ???};</script></body></html>
navigator对象
//通过platform属性可以判断浏览器所在的系统平台类型.//console.log(window.navigator.platform);
定时器
<script>//setInterval函数返回timeId ?var timeId = setInterval(function () { ???alert("hello");//每隔一秒弹框 ?}, 1000); ?document.getElementById("btn").onclick = function () { ???//点击按钮,停止定时器 ???//参数:要清理的定时的id的值 ???window.clearInterval(timeId); ?};</script>
JS之BOM的几个对象
原文地址:https://www.cnblogs.com/hzdwwzz/p/10332134.html