最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js檢測(cè)IE8及以下瀏覽器版本并做出提示的函數(shù)代碼

 更新時(shí)間:2023年02月08日 15:46:04   投稿:mdxy-dxy  
這篇文章主要介紹了js檢測(cè)IE8及以下瀏覽器版本并做出提示的函數(shù)代碼,需要的朋友可以參考下

使用原生js檢測(cè)當(dāng)前IE瀏覽器版本是否為IE8及一下瀏覽器版本并做出提示,代碼如下:

代碼一userAgent

通過(guò)userAgent,然后再使用正則匹配出版本信息。

var DEFAULT_VERSION = 8.0;
var ua = navigator.userAgent.toLowerCase();
var isIE = ua.indexOf("msie")>-1;
var safariVersion;
if(isIE){
safariVersion =  ua.match(/msie ([\d.]+)/)[1];
}
if(safariVersion <= DEFAULT_VERSION ){
  // 進(jìn)行你所要的操作
$(".wrap").before('<div class="low_version">系統(tǒng)檢測(cè)到您正在使用ie8以下內(nèi)核的瀏覽器,不能實(shí)現(xiàn)完美體驗(yàn),請(qǐng)及時(shí)更新瀏覽器版本!</div>');
};

代碼二documentMode

作為當(dāng)今最差的瀏覽器,雖說(shuō)IE即將推出歷史的舞臺(tái),但是因?yàn)轫?xiàng)目需要還是需要支持。那么必須判斷是否是IE,如果是IE,需要做些特殊處理。

document.documentMode 是IE特有的屬性,可以根據(jù)這個(gè)值判斷是否為IE。如:

var isIE =  document.documentMode !== undefined;

確實(shí)是簡(jiǎn)單好用吧 :)

基本來(lái)說(shuō),document.documentMode的值就是IE的版本號(hào),如:

7 - The page is displayed in IE7 mode
8 - The page is displayed in IE8 mode
9 - The page is displayed in IE9 mode
10 - The page is displayed in IE10 mode
11 - The page is displayed in IE11 mode

function IEVersion () {
    if (document.documentMode) return document.documentMode;
  }
  if (IEVersion()<=8) {
    alert("低于ie8");
  }

documentMode屬性

1、定義和用法:

The documentMode property returns the mode used by the browsers to render the current document.

documentMode屬性返回瀏覽器渲染當(dāng)前文檔所用的模式。

IE8 can render a page in different modes,depending on the !DOCTYPE or the presence of certain HTML elements.

IE8可以以不同的模式渲染一個(gè)頁(yè)面,主要依賴于!DOCTYPE或者當(dāng)前的某一個(gè)HTML元素。

按照下列的值返回:

5   ----- in IE5 mode
7   ----- in IE7 mode
8   ----- in IE8 mode
9   ----- in IE9 mode
注釋?zhuān)?如果沒(méi)有定義!DOCTYPE,IE8以IE5的模式來(lái)渲染頁(yè)面

2、 語(yǔ)法:

document.documentMode

3、瀏覽器支持:

 documentMode 是一個(gè)IE的私有屬性,在IE8+中被支持。

代碼三

/***
 * 獲取系統(tǒng)的當(dāng)前IE瀏覽器版本
 * @returns 
 */
function getExplorerInfo() {
    var explorer = window.navigator.userAgent.toLowerCase();
    //ie 
    if (explorer.indexOf("msie") >= 0) {
        var ver = explorer.match(/msie ([\d.]+)/)[1];
        return { type: "IE", version: ver };
    }
}

function checkBrowser(){
	var DEFAULT_VERSION = "8.0";
	var ua = navigator.userAgent.toLowerCase();
	var isIE = ua.indexOf("msie")>-1;
	var safariVersion=null;
	if(isIE){
	    safariVersion =getExplorerInfo().version;
	    if(safariVersion <= DEFAULT_VERSION ){
	        window.location.href= contextPath+"/Browser.jsp"; 
	    }else{
	        return;
	    }
	}else{
	    return;
	}
}

到此這篇關(guān)于js檢測(cè)IE8及以下瀏覽器版本并做出提示的函數(shù)代碼的文章就介紹到這了,更多相關(guān)IE8以下瀏覽器版本內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

阿克| 金华市| 安阳县| 牡丹江市| 南澳县| 乌恰县| 宁国市| 江北区| 台南县| 隆尧县| 卓尼县| 平利县| 陕西省| 平阳县| 万全县| 凯里市| 松潘县| 开江县| 渝北区| 梅河口市| 宁国市| 高雄县| 东方市| 云浮市| 衡山县| 景德镇市| 邮箱| 桐柏县| 朝阳市| 读书| 迭部县| 新沂市| 吴桥县| 镇巴县| 孝感市| 岱山县| 洪雅县| 丽水市| 樟树市| 保亭| 商水县|