Database with UTF-8, the existing system with gb2312,
Use <SCRIPT> echo_script (URL); </SCRIPT>CopyCodeThe Code is as follows: <SCRIPT>
Function echo_script (URL ){
VaR useragent = navigator. useragent. tolowercase ();
VaR bname = '';
VaR B = ['ie', 'msie ', 'Firefox', 'chrome ', 'Opera', 'safari ', 'maxthon', 'mozilla ', 'webkit'];
For (I in B ){
If (useragent. indexof (B [I])>-1 ){
Bname = B [I];
Break;
}
}
If (! Bname) bname = 'other ';
VaR IE8 = useragent. indexof ('msie 8')>-1? 'Ie8': false;
VaR IE7 = useragent. indexof ('msie 7')>-1? 'Ie7': false;
If (bname = 'Firefox '| IE8)
{
VaR ENC = "no ";
}
If (IE8 ){
Bname = 'ie8 ';
} Else if (IE7 ){
Bname = 'ie7 ';
}
VaR tmp_ie8 = IE8? 'Ie8': 'No _ ie8 ';
Document. write ("<SCRIPT src = '" + URL + "& encode =" + ENC + "& browser =" + tmp_ie8 + "& browserv =" + bname + "'> <\/SCRIPT> ");
}
</SCRIPT>
Ah, this method causes me to get garbled characters in different browsers.
There is a simpler way
<SCRIPT type = "text/JavaScript" charset = "UTF-8" src = "xx.com/xx.php"> </SCRIPT>
Garbled characters no longer appear!