html editor with preview

Discussion in 'Javascript' started by Gernot Frisch, Mar 8, 2006.

  1. Hi,

    I'd like to have an textarea, where I type HTML code. While typing,
    I'd like to see the result at the bottom of the page (in a DIV?) to be
    show.
    Can you help?

    --
    -Gernot
    int main(int argc, char** argv) {printf
    ("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
     
    Gernot Frisch, Mar 8, 2006
    #1
    1. Advertising

  2. Got it - don't bother:
    <html>
    <head>


    </head>

    <body>
    <form name="Input">
    <textarea name="text_in" style="width:100%; height:40%">Sample
    text</textarea>
    <br>
    <div id=b
    onclick="document.getElementById('preview').innerHTML=document.Input.text_in.value">
    </div>
    </form>

    <div id="preview">
    </div>
    <script language="Javascript">
    var elapse = 1000; // this is interval - 1000 millisecond
    function onTimer()
    {
    document.getElementById('preview').innerHTML=document.Input.text_in.value;
    timer = window.setTimeout("onTimer()",elapse);
    }

    onTimer();
    </script>
    </body>
    </html>
     
    Gernot Frisch, Mar 8, 2006
    #2
    1. Advertising

  3. JRS: In article <>, dated Wed, 8 Mar 2006
    12:04:18 remote, seen in news:comp.lang.javascript, Gernot Frisch
    <> posted :

    ><body>
    ><form name="Input">
    > <textarea name="text_in" style="width:100%; height:40%">Sample
    >text</textarea>
    > <br>
    > <div id=b
    >onclick="document.getElementById('preview').innerHTML=document.Input.text_in.val
    >ue">
    > </div>
    ></form>
    >
    ><div id="preview">
    ></div>
    ><script language="Javascript">
    > var elapse = 1000; // this is interval - 1000 millisecond
    > function onTimer()
    > {
    > document.getElementById('preview').innerHTML=document.Input.text_in.value;
    > timer = window.setTimeout("onTimer()",elapse);
    > }
    >
    > onTimer();
    ></script>
    ></body>


    I suspect the onClick is redundant; and it might be better to call the
    function with body onLoad.

    If the HTML may include controls, and data should be put by the user
    into the controls for test, then ISTM necessary to be able to turn off
    the function, for otherwise the controls will probably be continually
    reinitialised.

    See also <URL:http://www.merlyn.demon.co.uk/js-quick.htm>, to which I
    might add such a feature.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Mar 10, 2006
    #3
    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. UJ
    Replies:
    1
    Views:
    475
    =?Utf-8?B?TmV0IERldmVsb3Blcg==?=
    Jun 13, 2005
  2. Stylus Studio
    Replies:
    0
    Views:
    736
    Stylus Studio
    Aug 3, 2004
  3. Fil

    preview of a html report

    Fil, Sep 14, 2005, in forum: HTML
    Replies:
    1
    Views:
    367
    Toby Inkster
    Sep 15, 2005
  4. Chris

    HTML Preview

    Chris, May 24, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    427
    Richard Brown
    May 24, 2006
  5. Jonathan Fine
    Replies:
    0
    Views:
    109
    Jonathan Fine
    Apr 1, 2008
Loading...

Share This Page