简体   繁体   English

jWYSIWYG将换行符变成 <P> 在IE9中,但是 <BR> 在其他浏览器中

[英]jWYSIWYG turns newlines into <P> in IE9, but into <BR> in other browsers

I'm using jWYSIWYG jquery plugin to add controls to textareas in an application. 我正在使用jWYSIWYG jquery插件向应用程序中的textareas添加控件。

I found that the same code in IE turns newlines into <P> tags, but <BR> in other browsers (Firefox, Chrome, so far). 我发现IE中的相同代码将换行符转换为<P>标记,而在其他浏览器(到目前为止,Firefox,Chrome)中将<BR>转换为<BR> Ideally I'd like them all to be <BR> , or barring that, make them all <P> . 理想情况下,我希望它们全部为<BR> ,或者除此以外,使它们全部为<P> I at least want it to be consistant. 我至少希望它保持一致。

Is there a work around? 有没有解决的办法? I see that there is a config setting: 我看到有一个配置设置:

brIE A boolean. brIE一个布尔值。 If true , a <br/> will be inserted for a newline in IE. 如果为true ,将在IE中为换行符插入<br/>

Unfortunately, it doesn't seem to do anything when set. 不幸的是,设置后它似乎什么也没做。

The root of the issue here is that browser-based WYSIWYG editors use the browser to do the editing. 问题的根源在于基于浏览器的所见即所得编辑器使用浏览器进行编辑。

The base component of a WYSIWYG editor is just a standard element (eg a <div> ) with the contentEditable flag set. 所见即所得编辑器的基本组件只是带有contentEditable标志设置的标准元素(例如<div> )。 That's it. 而已。 The browser takes control of actually doing the editing; 浏览器控制实际进行的编辑; the javascript code is not in control of this, the browser is. JavaScript代码不受此控制,浏览器受此控制。 And different browsers implement it differently. 并且不同的浏览器实现它的方式也不同。

That's why you get different results from different browsers. 因此,您从不同的浏览器获得不同的结果。 There's not a lot you can do about it really within the editor. 在编辑器中,您实际上无能为力。 You'll even find that if you load content that was created in browser into a different browser, it will be reformatted to how the new browser wants it to be, often without you even doing any actual editing. 您甚至会发现,如果将在浏览器中创建的内容加载到其他浏览器中,它将被重新格式化为新浏览器的期望格式,通常甚至无需进行任何实际编辑。

This will happen with all browser-based WYSIWYG editors. 所有基于浏览器的WYSIWYG编辑器都将发生这种情况。 Some of them may attempt to normalise the browser differences, but with limited success as you've seen. 他们中的一些人可能试图规范化浏览器之间的差异,但是如您所见,成功率有限。 And the user does have some control; 用户确实拥有一些控制权; eg browsers will often react differently to shift + return compared with just return for new-lines. 例如,浏览器往往会产生不同的反应,以回报 +只返回新行相比偏移 But that leaves it in the hands of the user, who may not be aware of the need to do so (after all, you use a wysiwyg editor to make things easier for the user, not more complicated). 但这使它交由用户掌握,而用户可能并不知道这样做的必要性(毕竟,您使用所见即所得的编辑器可以使用户更轻松,而不是更复杂)。

So overall, the best you can really hope for is to normalise it after it's been edited, in your server-side code. 因此,总的来说,您真正希望的最好的办法是在服务器端代码中对其进行编辑后对其进行规范化。

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

相关问题 IE9中对ColdFusion CFC的Ajax调用未完成,在其他浏览器中可以 - Ajax call to ColdFusion CFC in IE9 not completing, OK in other browsers Angular JS不使用IE9,但可以与其他浏览器一起使用 - Angular JS not working with IE9 but works with other browsers 问题,网站适用于FF4但不适用于IE9或其他浏览器 - Problem, site works on FF4 but not IE9 or other browsers IE8不能与jQuery .show()一起使用,并且不能在所有其他浏览器(包括ie9)上使用 - IE8 not working with jQuery .show() and working on all other browsers including ie9 除IE以外的所有其他浏览器的CSS - css for all other browsers but IE 将换行符转换为 <br> 在标签中 - Convert newlines to <br> in a label 使用JQuery调用WebService并非在所有浏览器中都有效,而仅在IE9中有效吗? - Calling WebService using JQuery not working in all browsers but only in IE9? Flipbook(turn.js)转一圈,然后在IE9和iPhone版Chrome中损坏 - Flipbook (turn.js) turns once then breaks in IE9 and Chrome for iPhone onreadystatechange 在 IE11 中有效,但在其他浏览器中无效 - onreadystatechange works in IE11 but not in other browsers 脚本可以在除IE之外的所有其他浏览器中完美运行 - Script runs perfectly in all other browsers but IE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM