Can textareas be styled with javascript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Kirk

    #1

    Can textareas be styled with javascript?

    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

    #2
    Re: Can textareas be styled with javascript?


    "Jason Kirk" <usenet@captain .custard.org> wrote in message
    news:pan.2005.0 6.12.02.21.56.1 9594@captain.cu stard.org...[color=blue]
    > 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
    >
    >[/color]


    Comment

    • Martin Honnen

      #3
      Re: Can textareas be styled with javascript?



      Jason Kirk wrote:
      [color=blue]
      > 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?[/color]

      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/

      Comment

      • RobG

        #4
        Re: Can textareas be styled with javascript?

        Jason Kirk wrote:[color=blue]
        > 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.
        >[/color]

        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>bl ah</B></textarea> --> <B>blah</B>

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

        Also:

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

        and (when clicked on):

        <textarea onclick="this.v alue="blah\nbla h">

        --> blah
        blah



        --
        Rob

        Comment

        Working...