Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Syntax highlighting in TEXTAREA - possible?
October 22, 2005, 8:59 pm
rate this thread
Hi - I am battling to find the a resource, so maybe some one in here can
The problem is as follows: I am trying to build a mod_perl source code
editor for the web - to edit Perl source code in a browser. The trick is
that I want to add syntax highlighting
to a HTML TEXTAREA tag. There are millions of resources for just normal
text color and background colors (and images), but nothing on keyword
Any help will be appreciated.
O yes - this is for an Open Source project I am planning
Using Opera's revolutionary e-mail client: http://www.opera.com/mail /
Re: Syntax highlighting in TEXTAREA - possible?
The HTML 4/XHTML 1 textarea control is a plain text edit control so
there is no way to have some characters or words in that control
highlighted. Some browsers (IE/Win, Mozilla since 1.4, Opera since 8.0)
by now allow script to manipulate the selection in a textarea so there
you can use script to select some text in the textarea.
If you want to build a Perl source code editor with syntax hightlighting
then you need to look into editable HTML elements which some browsers
implement, IE/Win (since IE 5) and Mozilla since 1.4 (and Opera 9.0
Preview 1) allow editable iframes where you can set the designMode
property of the document object to 'on' with script and then the user
can edit the current document in the iframe and script can of course
manipulate that too.
See <http://www.mozilla.org/editor/midas-spec.html> for the Mozilla
documentation on that. msdn.microsoft.com has the specification for IE/Win.
IE 5.5 and later on Windows additionally support editable elements in a
document by setting e.g.
so that way you do not need a complete iframe but can have part of your
That way you can do your syntax editor with editable markup and CSS.