robert.waters@gmail.com wrote:
[color=blue]
> I am dynamically editing the contents of a page and using
> document.write() to reload the new, edited content.[/color]
[color=blue]
> (This just rewrites the page with the function to rewrite it removed;
> what I'm doing is more complicated)
> start
> <script src="path-to-script.js">[/color]
Where is the closing </script> tag then?
[color=blue]
> <script>
> function test() {
> // I'm actually using xmlhttp GET (irrelevant)
> var h = document.getElementByTagName('html').innerHTML;[/color]
Perhaps you want
var h = document.documentElement.innerHTML
? Or at least
var h = document.getElementsByTagName('html')[0].innerHTML;
?[color=blue]
> h = h.replace(/start(.*?)end/m,'');
> document.open();
> document.write(h);
> document.close();[/color]
So the new markup written has no <html> root element at all as you use
innerHTML of the root element?
And browsers for many years by now have various object models allowing
you to replace or manipulate parts of the document, why on earth are you
trying to rewrite the complete HTML markup with some string replacement
applied?
Ever heard of the IE DOM (e.g. setting and getting innerHTML and
outerHTML on elements exposed in the DOM tree, insertAdjacentHTML) and
the W3C DOM (replaceChild, removeChild)?
--
Martin Honnen
http://JavaScript.FAQTs.com/