Can textareas be styled with javascript?

Discussion in 'Javascript' started by Jason Kirk, Jun 12, 2005.

  1. Jason Kirk

    Jason Kirk Guest

    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
    Jason Kirk, Jun 12, 2005
    #1
    1. Advertising

  2. http://www.brayneychyled.com/helpoutsometimes.htm
    "Jason Kirk" <> wrote in message
    news:p...
    > 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
    >
    >
    Sympatico Member, Jun 12, 2005
    #2
    1. Advertising

  3. Jason Kirk wrote:

    > 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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jun 12, 2005
    #3
  4. Jason Kirk

    RobG Guest

    Jason Kirk wrote:
    > 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



    --
    Rob
    RobG, Jun 14, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    1
    Views:
    662
    Steven Cheng[MSFT]
    Aug 16, 2005
  2. MacEgan
    Replies:
    2
    Views:
    348
    Andrew Thompson
    Dec 17, 2005
  3. MacEgan
    Replies:
    1
    Views:
    301
    IchBin
    Dec 17, 2005
  4. Guy
    Replies:
    1
    Views:
    38,041
  5. Jeff Thies

    Page test: expando textareas

    Jeff Thies, Jul 2, 2004, in forum: HTML
    Replies:
    4
    Views:
    391
    Blinky the Shark
    Jul 2, 2004
Loading...

Share This Page