美文网首页
BOM操作-3:history历史记录 / navigator设

BOM操作-3:history历史记录 / navigator设

作者: kino2046 | 来源:发表于2019-10-18 02:12 被阅读0次

history历史

        1.back()    返回历史记录上一步

        2.forward()    到历史记录下一步

        3.go()    前进几步,负数后退

        4.state()    正课中解说

        5.pushState()    正课中解说

        6.popstate()    正课中解说


navigator设备信息

        userAgent 用户代理信息

        appName    浏览器名称

        appVersion    浏览器版本号

        onLine 网络信息 true 有网,false 无网

// 判断PC

function IsPC() {

    var userAgentInfo = navigator.userAgent;

    var Agents = ["Android", "iPhone",

                "SymbianOS", "Windows Phone",

                "iPad", "iPod"];

    var flag = true;

    for (var v = 0; v < Agents.length; v++) {

        if (userAgentInfo.indexOf(Agents[v]) > 0) {

            flag = false;

            break;

        }

    }

    return flag;

}

// 判断设备

var ua = navigator.userAgent.toLowerCase();

if (/android|adr/gi.test(ua)) {

    // 安卓

}else if(/\(i[^;]+;( U;)? CPU.+Mac OS X/gi.test(ua)){

    //苹果

}

// 判断不同客户端:新浪微博为1,QQ客户端为2,微信低于6.0.2版本为3,高于6.0.2版本为4,其他为0。

var ua = navigator.userAgent.toLowerCase();  

if(ua.match(/weibo/i) == "weibo"){  

    console.log(1);

}else if(ua.indexOf('qq/')!= -1){  

    console.log(2);

}else if(ua.match(/MicroMessenger/i)=="micromessenger"){  

var v_weixin = ua.split('micromessenger')[1];  

    v_weixin = v_weixin.substring(1,6);  

    v_weixin = v_weixin.split(' ')[0];  

if(v_weixin.split('.').length == 2){  

    v_weixin = v_weixin + '.0';  

}  

if(v_weixin < '6.0.2'){  

    console.log(3);

}else{  

    console.log(4);  

}  

}else{  

    console.log(0); 

}

// 区分各个浏览器

var ua=navigator.userAgent.toLowerCase();  

if(/msie/i.test(ua) && !/opera/.test(ua)){  

    alert("IE");  

    return ;  

}else if(/firefox/i.test(ua)){  

    alert("Firefox");  

    return ;  

}else if(/chrome/i.test(ua) && /webkit/i.test(ua) && /mozilla/i.test(ua)){  

    alert("Chrome");  

    return ;  

}else if(/opera/i.test(ua)){  

    alert("Opera");  

    return ;  

} else if(/webkit/i.test(ua) &&!(/chrome/i.test(ua) && /webkit/i.test(ua) && /mozilla/i.test(ua))){  

    alert("Safari");  

    return ;  

}else{  

    alert("unKnow");  

}


screen    屏幕

        常用 width,height


相关文章

  • JS第七天-04

    BOM 代码示例: 1、窗口操作 open 2、历史记录 history 3、导航器 navigator 4、地址...

  • 029 BOM

    BOM 1、窗口操作 open 2、历史记录 history 3、导航器 navigator 4、地址信息 loc...

  • BOM操作-3:history历史记录 / navigator设

    history历史 1.back() 返回历史记录上一步 2.forward() 到历史记录下一步 3.go(...

  • BOM对象

    BOM常用对象 1.BOM的常用对象: window navigator history location...

  • BOM对象(一)———window对象

    bom对象分为:window对象,Navigator对象,Screen对象,History对象,Location对...

  • js浏览器bom对象

    1.常用的bom对象 window、location、history、navigator、document 2.w...

  • Window

    这里介绍一下Window screen 屏幕 history 历史记录 location navigator us...

  • BOM navigator对象、history对象

    一、navigator对象 navigator对象包含有关浏览器的信息,最常用的属性是userAgent,该属性可...

  • Linux学习笔记-day1

    简单操作指令 history 执行历史命令 !对应数字 history -c 清除;历史记录 tab补全,双tab...

  • 5-9 BOM操作-代码演示

    5-9 BOM操作-代码演示 UA > console.log(navigator.userAgent) [Log...

网友评论

      本文标题:BOM操作-3:history历史记录 / navigator设

      本文链接:https://www.haomeiwen.com/subject/wpmbmctx.html