html editor with preview

G

Gernot Frisch

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?
 
G

Gernot Frisch

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

Dr John Stockton

JRS: In article <[email protected]>, dated Wed, 8 Mar 2006
12:04:18 remote, seen in Gernot Frisch
<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.
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top