Hi. I have the following script on my page
[code=html]<script type=”text/javascript”>
<!–
escapeHTML(‘<ul id=”nav”><li><a href=”http://www.google.com”>text</a><ul><li><a href=”http://www.google.com”>text</a> <ul><li><a href=”http://www.google.com”>text</a></li></ul></li></ul></li></ul>’);
function escapeHTML(text) {
text = text.replace(new RegExp(/</g),”<”)
text = text.replace(new RegExp(/>/g),”>”)
document.writeln( text.toLowerCase() );
}
//–>
</script>
The idea is to write the HTML code for a bulleted list to a page without actually rendering it.
This code works great except the written results are all on one line. What i need is for the results to be indented as if i were writing it in an editor. i.e.
[code=html]<ul id=”nav”>
<li><a href=”http://www.google.com”>text</a>
<ul>
<li><a href=”http://www.google.com”>text</a>
<ul>
<li><a href=”http://www.google.com”>text</a></li>
</ul>
</li>
</ul>
</li>
</ul>
The only caveat is – i cannot change the string that is passed to the escapeHTML function in any way. Can this be done?