简体   繁体   English

Chrome / Firefox中的HTML编码

[英]HTML encoding in chrome/firefox

I have a textBox whose value is getting displayed in different Manner in IE and chrome. 我有一个textBox,其值正以IE和chrome中的不同方式显示。

For example : 例如 :

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

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

Output in Chrome : <input id="myInput" type="text" value=" "> Chrome中的输出: <input id="myInput" type="text" value=" ">

How to achieve the same behavior like IE8 in chrome? 如何在Chrome中实现类似IE8的行为? I do not want to set the value separately 我不想单独设置值
using javascript or jquery. 使用javascript或jquery。 This value has to be there in html file while rendering. 呈现时,该值必须存在于html文件中。

You must set meta in head 您必须在头部设置meta

<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; IE 8(和IE 9)在处理&#0;时出错&#0; . This reference means the NULL character, which is invalid in HTML. 此引用表示NULL字符,在HTML中无效。 HTML5 specifies that the error be processed so that NULL is replaced by U+FFFD REPLACEMENT CHARACTER “ ”. HTML5 指定要处理的错误,以便将NULL替换为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; 如果您确实想将input元素的默认(初始)值设置为文字字符串&#0; (four Ascii characters), use value="&amp;#0;" (四个Ascii字符),请使用value="&amp;#0;" , ie the normal &amp; ,即正常&amp; escape for & . &逃脱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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