Re: Can't use Firefox innerHTML() on XHTML page?
Martin Honnen <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
GregH wrote:
> Hi,
>
> I've written a very simple bookmarklet, which uses innerHTML to create
> new DOM elements on a webpage:
>
> (function(){
> var testDiv = document.createElement( 'div' );
> testDiv.innerHTML = "<p>I don't display</p>";
> document.body.appendChild(testDiv);
> })()
>
> For easy copying into a bookmark:
>
> javascript:(function(){var%20testDiv=document.createElement
> ('div');testDiv.innerHTML="<p>I%20don't%20display</
> p>";document.body.appendChild(testDiv);})()
>
> Unfortunately, in Firefox 3.0.8, this bookmarklet blows up when
> applied on this XHTML webpage: http://direct.tesco.com/q/R.200-3522.aspx
>
> The Firebug error is:
>
> uncaught exception: [Exception... "Component returned failure code:
> 0x80004003 (NS_ERROR_INVALID_POINTER)
> [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003
> (NS_ERROR_INVALID_POINTER)" location: "JS frame :: javascript:
> (function(){var%20testDiv=document.createElement
> ('div');testDiv.innerHTML="<p>I%20don't%20display</
> p>";document.body.appendChild(testDiv);})() :: anonymous :: line 1"
> data: no]
>
> Can anyone explain why this doesn't work?
It seems to be related to that URL, when I try that code with other
application/xhtml+xml documents I don't get any error.
I am however not sure what on that URL causes the problem.
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/