开发者

FCKEditor replaces & with & when switching from source to design view?

开发者 https://www.devze.com 2023-03-14 10:09 出处:网络
I have the problem that my installed FCKEditor 3.3.1 changes all & to &. I am posting lots of links in my posts and this makes them invalid. Where can I define that & ist NOT replace

I have the problem that my installed FCKEditor 3.3.1 changes all & to &.

I am posting lots of links in my posts and this makes them invalid. Where can I define that & ist NOT replaced with &?

T开发者_开发技巧hanks :-)


No, you can't. FCKEditor does the right thing.

There is no situation where a standalone & in HTML is not an error. The ampersand always has to be encoded as & - unless it is the start of an escape sequence itself (like in <).

It is a misconception that the & in the HTML source code would make a link invalid. It does not. For HTML to be valid, all data in it must be HTML-escaped. "Data" means both text (in-between tags) and attribute values (like href). When the HTML source is then parsed, the parser will automatically HTML-unescape all data and & will become & again in the DOM. Do not let the fact that many browsers accept an unescaped ampersand deceive you. It is wrong nevertheless (and FCKEditor just tries to deliver valid HTML).


See the custom setting in the fckconfig.js file for FCKeditor.

FCKConfig.ForceSimpleAmpersand  = true ;

Tomalak is correct about how it should be presented but I'm just pointing out that there is a configuration option in FCKeditor, in case you need to "break the rules". There are situations where this is necessary. Rendering the ampersand as a true HTML entity (&) does not work in some HTML mail clients, which rarely adhere to HTML standards properly anyway. And you may need to force the plain ampersand if you have an additional filter that will convert it to an HTML entity further along your process.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号