码迷,mamicode.com
首页 > Web开发 > 详细

获取网页编码

时间:2014-08-26 11:59:07      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:style   http   color   java   io   for   ar   cti   html   

[javascript]  

if(document.charset){  

    document.writeln(‘<script src="http://www.zzwcw.com/swt/bottomfloat.js" charset="GBK"></script>‘);  

}else if(document.characterSet){  

document.writeln(‘<script src="http://www.zzwcw.com/swt/bottomfloat.js" charset="utf-8"></script>‘);  

}  

 

 

 

[javascript]  

<html>  

<head>  

   <meta http-equiv="content-type" content="text/html; charset=gbk">  

</head>  

<script  type="text/javascript">  

function getPageCharset(){  

    var charSet = "";  

    var oType = getBrowser();  

    switch(oType){  

        case "IE":  

            charSet = document.charset;  

            break;  

        case "FIREFOX":  

            charSet = document.characterSet;  

            break;  

        case "CHROME":  

          charSet = document.characterSet;  

            break;  

        default:  

            break;  

    }  

    return charSet;  

}  

function getBrowser(){  

    var oType = "";  

    if(navigator.userAgent.indexOf("MSIE")!=-1){  

        oType="IE";  

    }else if(navigator.userAgent.indexOf("Firefox")!=-1){  

        oType="FIREFOX";  www.2cto.com

    }else if(navigator.userAgent.indexOf("WebKit")!=-1 ){  

      oType="CHROME";  

    }  

    return oType;  

}  

alert(getPageCharset());  

</script>  

<body>  

     

</body>  

</html>  

获取网页编码

标签:style   http   color   java   io   for   ar   cti   html   

原文地址:http://my.oschina.net/u/1035715/blog/306640

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!