Database with UTF-8, the existing system with gb2312,
Use <script> echo_script (url); </script>
Copy codeThe 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!