博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

A5000项目阅读笔记

Posted on 2019-08-05 09:02  追风0315  阅读(153)  评论(0编辑  收藏  举报

1: javascript 中 if (window != top)  top.location.href = location.href;

   如果当前窗口不是顶级窗口,就强制修改为顶级窗口;

   目的是为了不让别人用iframe嵌入你的页面

 

2:JS判断PC操作系统版本

 

var version = navigator.userAgent;
console.log(version);
//"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3223.0 Safari/537.36" 
if(version.indexOf("Windows NT 5")!=-1) { 
    console.log("这是XP系统");
}else if(version.indexOf("Windows NT 7")!=-1){
    console.log("这是win7系统");
}else if(version.indexOf("Windows NT 10")!=-1){
    console.log("这是win10系统");
}

 

3:检测浏览器是否过时outdatedBrowserRework
 
 
4:阻止浏览器前进后退
 history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
});
View Code