Click to See Complete Forum and Search --> : Disabling HTML for JavaScript parsing


whiskey
08-17-2003, 08:27 PM
I have a javascript script that displays a two-column table representing the layout for everyone of my pages. The first column has the menu which is the same for every page. But the second column has the page content which is different for each page.

Inside the script, I read off the contents of a tag containing a certain id (using innerHTML method) and dump that inside the second column. This is the page's main content.

However, I don't want the HTML tag to be parsed twice since this can lead to some functionality problems.

Is there a nice way of preventing the tag's contents to be html parsed?

I used this hack and it seems to do the trick:

<script type=text id=content>
html goes here
</script>

But I'm worrying that it might break on other browsers.

pyro
08-17-2003, 08:34 PM
You could possibly use the depreciated <xmp> tag to do it, but I would highly recommend using a serverside langague to do this.

whiskey
08-17-2003, 09:19 PM
Thank you for the reply. <xmp> worked fine. It's deprecated but I don't see a standard alternative for it. I tried the <pre> tag but the html code within it is parsed.

pyro
08-17-2003, 09:21 PM
Yeah, there really isn't an (exact) alternative for it. With <pre> you need to change all the < to &lt; and the > to &gt;