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

 

相关文章:

  • 2021-10-16
  • 2021-12-06
  • 2021-12-02
  • 2021-05-15
  • 2021-12-27
  • 2021-05-29
  • 2021-12-10
  • 2021-06-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
相关资源
相似解决方案