获取网页编码
[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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。