Garbled content in the alert dialog box of javascript
Source: Internet
Author: User
When the charset page is a Utf-8 and the file is UTF-8 encoded, garbled characters appear in the alert dialog box of javascript. This is because the Chinese browser uses the default encoding in the write method below gb2312, And the content in the alert dialog box will be garbled & lt ;? Phpecho & amp; #39; & lt; script & gt; alert (& quot; I am... when the charset page is a Utf-8 and the file is UTF-8 encoded, garbled characters appear in the alert dialog box of javascript.
This is because the Chinese browser uses the default encoding gb2312.
In the following writing method, garbled characters will appear in the alert dialog box.
Echo 'script alert ("I Am a dialog box"); location. href = "config. php"; script ';
?>
.....................
This is because the browser has not received the page encoding UTF-8, And the dialog box is displayed, which is the default gb2312.
Just change it to the following.
Echo 'script alert ("I Am a dialog box"); location. href = "config. php"; script ';
?>
.....................
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.