zl程序教程

您现在的位置是:首页 >  前端

当前栏目

判断浏览器的类型

浏览器 类型 判断
2023-09-14 09:13:42 时间
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>判断浏览器的类型</title>
<script src="jquery-1.8.3.min.js"></script>  <!-- 引入合适的jq -->
</head>
<body>
<div class="">判断浏览器的类型</div>
</body>


<script>
$(document).ready(function() {
// If the browser type if Mozilla Firefox
if ($.browser.mozilla && $.browser.version >= "1.8" ){ 
// some code
}
// If the browser type is Opera
if( $.browser.opera)
{
alert(1);
// some code
}
// If the web browser type is Safari
if( $.browser.safari )
alert(2);
{
// some code
}
// If the web browser type is Chrome
if( $.browser.chrome)
alert("我是谷歌");
{
// some code
}   //以上浏览器判断都是可以的
// If the web browser type is Internet Explorer
if ($.browser.msie && $.browser.version <= 6 )
alert(4);
{
// some code
}
//If the web browser type is Internet Explorer 6 and above
if ($.browser.msie && $.browser.version > 6)
alert(5);
{
// some code
}
});
</script>
</html>