Skip to content

Instantly share code, notes, and snippets.

@adison
Created July 31, 2013 04:08
Show Gist options
  • Save adison/6119198 to your computer and use it in GitHub Desktop.
Save adison/6119198 to your computer and use it in GitHub Desktop.
檢查瀏覽器版本
//檢查版本
function checkBrowserVersion(){
var isShowBrowserNotice = false;
var N= navigator.appName, ua= navigator.userAgent, tem;
var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
M= M? [M[1], M[2]]: [N, navigator.appVersion, '-?'];
var version = M[1].substring(0, M[1].indexOf("."));
//chrome < 15, firefox <2, ie <8 出现提示
if((M[0]== "Chrome" && 15 > parseInt(version)) || (M[0]== "Firefox" && 2 > parseInt(version)) || (M[0]== "MSIE" && 8 > parseInt(version)))
$('#browserNotice').show();
}
$(document).ready(function () {
checkBrowserVersion();
});
<div id="browserNotice" class="browserNotice" style="display:none;">
為了更好的瀏覽體驗,本網站最佳瀏覽環境為 1024 x 768 視窗模式以上,IE 8.0、Firefox 2.0、Chrome 15.0 以上版本瀏覽器。</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment