在js中不仅有dom对象还存在bom对象,下面来简单说说bom对象原型
-
location
location.href;//返回URL
location.hostname;//返回web主机域名
location.pathname;//返回当前页面的路径和文件名
location.port;//返回web主机的端口
location.protocol;//返回使用的web协议
注意:不能使用window这个前缀。 -
history
history.back();//返回上一个地址
history.forward();//返回下一个地址 -
navigator
navigator.attribute;//返回当前浏览器的信息 -
弹窗alert();//提示
confirm(“sometext”);//警告
prompt(“sometext”,“默认”);//输入数据并继续 -
setInterval 与setTimeOut
setInterval(function(){},时间);//间隔相同的时间执行相同的代码,1000ms为1秒
clearInterval(a);//停止
setTimeOut(function(){},时间);//设置方法执行的时间
clearTimeOut(a);//停止,你必须在它设置的时间之前阻止它