Forum Moderators: open

Message Too Old, No Replies

Formating innerHTML with JavaScript

Formating innerHTML Object with JavaScript for beeing displayed in DIV

         

cyberskater

3:12 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



If you want to provide a WYSIWYG-Editor, your may offer the ability to switch between WYSIWYG and source mode.

Using JavaScript that may work like this:


if(the_args[x].srcMode!= 1)
{
the_args[x].innerText = the_args[x].innerHTML;
the_args[x].srcMode = 1;
the_args[x].style.fontFamily = "monospace";
the_args[x].style.fontSize = "8pt";
}
else
{
the_args[x].innerHTML = the_args[x].innerText;
the_args[x].srcMode = 0;
}

When the html is redered by XSL (client side rednering in IE 5.x), from an XML datasource, how can I make the output inside the target div area look like beautiful formated HTML (using javascript for this) like in an editor and not like:


<tag1>
<tag2>
</tag2>
<tag3>
<tag4>
</tag4>
</tag3>
</tag1>

Thanks.

DrDoc

5:09 pm on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



how can I make the output inside the target div area look like beautiful formated HTML

You can use child nodes and set the styles... kinda like this:

foobar = //some child node
foobar.style.color = 'red';

cyberskater

8:54 am on Jan 26, 2004 (gmt 0)

10+ Year Member



Thanks so far, but how can I indent single lines like in an editor?