获取网页编码

发布时间:2017-09-06 19:29:24
获取网页编码 [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=utf8">

</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>

,站群,专题系统

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:天门SEO http://tianmen.4567w.com