Can textareas be styled with javascript?

J

Jason Kirk

I'm going to be using a textarea to edit some XML data. It would make my
life easier if I could add some really simple dynamic syntax highlighting
to the textarea. Is this possible with javascript?

I suspect I'll have to hackdown a RTE wysiwyg script, but I'd rather just
stick with a nice simple textarea if I can.

-Jason
 
M

Martin Honnen

Jason said:
I'm going to be using a textarea to edit some XML data. It would make my
life easier if I could add some really simple dynamic syntax highlighting
to the textarea. Is this possible with javascript?

You can try to apply CSS (statically or dynamically with script) to the
textarea and some browsers might apply that CSS but of course then to
the whole content of the textarea and not to some content which you
probably want if you want to do syntax highlighting.
 
R

RobG

Jason said:
I'm going to be using a textarea to edit some XML data. It would make my
life easier if I could add some really simple dynamic syntax highlighting
to the textarea. Is this possible with javascript?

I suspect I'll have to hackdown a RTE wysiwyg script, but I'd rather just
stick with a nice simple textarea if I can.

The content of a textarea elements is PCDATA. General HTML markup is
ignored but character entities are not (at least in all the browsers I
tested).

For example:

<textarea><B>blah</B></textarea> --> <B>blah</B>

<textarea>&amp;blah&gt;</textarea> --> &blah>

Also:

<textarea>blah \n blah</textarea> --> blah \n blah

and (when clicked on):

<textarea onclick="this.value="blah\nblah">

--> blah
blah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top