简体   繁体   中英

HTML encoding in chrome/firefox

I have a textBox whose value is getting displayed in different Manner in IE and chrome.

For example :

<input id="myInput" type="text" value="&#0;"/>

Output in IE8 : <input id="myInput" type="text" value="&#0;">

Output in Chrome : <input id="myInput" type="text" value=" ">

How to achieve the same behavior like IE8 in chrome? I do not want to set the value separately
using javascript or jquery. This value has to be there in html file while rendering.

You must set meta in head

<head>
    <meta charset = "utf-8">
</head>

And set same encoding of this file

IE 8 (and IE 9) is in error when it comes to processing &#0; . This reference means the NULL character, which is invalid in HTML. HTML5 specifies that the error be processed so that NULL is replaced by U+FFFD REPLACEMENT CHARACTER “ ”.

There is no way to achieve the old erroneous handling in modern browsers.

If you actually wanted to set the default (initial) value of the input element to the literal string &#0; (four Ascii characters), use value="&amp;#0;" , ie the normal &amp; escape for & .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM