1.Navigator:*代表当前浏览器的信息,通过Navigator判断用户当前是什么浏览器
let agent=window.navigator.userAgent;
if(/chrome/i.test(agent))
alert("当前是谷歌浏览器");
else if(/firefox/i.test(agent))
alert("当前是火狐浏览器");
2.Location:
oBtn.onclick=function(){
console.log(window.location.href);//获取当前地址栏的地址
//设置当前地址栏的地址
//window.location.href="http://www.baidu.com";
//重新加载界面,(不一定会清楚缓存)
//window.location.reload();
//强制刷新界面,(会清楚缓存)
//window.loaction.reload(true);
}
3.History
//前进,前提是必须有可前进的网页
window.history.forward();//前进一个网页
window.history.go(2);//代表前进2个网页,2可以被任何数值替换
//后退
window.history.back();//后退一个网页
window.history.go(-2);//后退两个网页,-2可以被任何数值替换
//刷新
window.history.go(0);//前进/后退0个页面,相当于刷新