Deryck wrote:
> I thought about defining the area to be updated using a div. Something like
> this:
>
> <div id="results">Results will go here</div>
>
> with the javascript doing something like:
>
> var src = "blah blah blah";
> document.getElementById('results').childNodes[0].nodeValue = src;
>
> This works if src is just text. If it is HTML, say:
>
> var src="<p><a href=\"some_file.html\">Some file</a></p>";
>
> Then inside the div instead of getting a link to some_file.html I get the
> raw HTML.
>
> Is there either a way round this problem or a much better way of doing it in
> the first place?
Learn the DOM e.g.
var p = document.createElement('p');
var link = document.createElement('a');
a.href = 'some_file.html';
p.appendChild(a);
var resultsDiv = document.getElementById('results');
while (resultsDiv.hasChildNodes()) {
resultsDiv.removeChild(resultsDiv.lastChild);
}
resultsDiv.appendChild(p);
or help yourself with innerHTML
resultsDiv.innerHTML = '<p><a ...>...<\/a><\/p>';
--
Martin Honnen
http://JavaScript.FAQTs.com/