Js output List Implementation Code

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.