English 中文(简体)
How do Rich Text Editors in HTML documents achieve their rich text formatting?
原标题:

Could you please explain how the text in the textarea gets styled in rich-text editors? I ve tried to style text in the form but it doesn t change.

Is it JS that recognizes characters typed by the user? How s that done?


Edit:

After a bit of research (Google rules!), I ve found some excellent information. For others who might be interested, these links were very helpful to me:

问题回答

I think the answer is that what you re looking at is typically NOT an actual <textarea>. It s a <div> or <span> made to look like a text area. A regular HTML textarea doesn t have individual formatting of the text.

"Rich-Text editors" will have controls that modify the contents of the span/div with regular html markup (<strong>, <em>, etc.) to emulate a full-blown rich text editor

Usually, the rich text editor will provide a variable to specify a style sheet in. That style sheet will then be loaded and applied to the textarea (Most, if not all, rich text editors use a IFRAME to display the editor in, and obviously styles specified in the main document won t apply to it.)

It s a textarea when you send the HTML to the user but the editor replaced it with a div when it can start.

This way, the code gracefully degrades: Users with unsupported web browsers or disabled JavaScript can still edit the text in the textarea while all the other users get a nice rich text editor.

Basically, the TEXTAREA contents are used as the HTML source for the IFRAME.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签