欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

js 判断是不是原生的chrome

shiping1 的头像
//下面两个函数  判断浏览器是不是原生chrome
function _mime(where, value, name, nameReg) {
        var mimeTypes = window.navigator.mimeTypes,
            i;
 
        for (i in mimeTypes) {
            if (mimeTypes[i][where] == value) {
                if (name !== undefined && nameReg.test(mimeTypes[i][name])) return !0;
                else if (name === undefined) return !0;
            }
        }
        return !1;
    }
 
function _getChromiumType() {
        
 
        var isOriginalChrome = _mime('type', 'application/vnd.chromium.remoting-viewer');
 
        // 原始 chrome
        if (isOriginalChrome) {
            return 'chrome';
        }
        return '';
    }
    
    
function getScroll()
{
        var t=0;
        if(document.documentElement && document.documentElement.scrollTop){
            t = document.documentElement.scrollTop;}
        else if(document.body){
            t = document.body.scrollTop;
        }
        return t;
}
function getHeight()
{
    var t = 0;
    if(document.documentElement && document.documentElement.clientHeight){
            t = document.documentElement.clientHeight ;}
        else if(document.body){
            t = document.body.clientHeight;
    }
    return t;
 
 
}
var isWebkit = /webkit/.test(navigator.userAgent.toLowerCase());
//isWebkit是判断 webkit ; _getChromiumType是判断是不是原生的chrome
/*
if(isWebkit && _getChromiumType()=='chrome'){
     $(window).scroll(function(){
  $('#looyuouter').css('position','absolute');
  $('#floatTools').css('position','absolute');
  $('#gg').css('position','absolute');
        var tScroll = getScroll();
        t1 = tScroll+141;
        
        $('#looyuouter').css('top',t1+'px');
        
           
        t2 = tScroll+190;//滚动高度 + 离顶部的高度
        $('#floatTools').css('top',t2+'px');
        
        
        var tHeight =  getHeight();  
        //alert(tScroll); alert(tHeight);
       t3 = tScroll+tHeight-96;  //滚动高度 + 页面高度 - 本身高度
        $('#gg').css('top',t3+'px');
  });
}
*/
 
普通分类: