05-07-2003, 02:23 PM
I have a page with a IFRAME in it. I want to pass some html content from the main page to the IFRAME page, so i used insertAdjacentHTML in IE and it worked fine. But it didnt work in Netscape.
I searched the net and found out the alternative methods, but they are working fine if i want to transfer the html content within that page. How to transfer the html content to the Iframes page.
some one please help me immediately.
05-07-2003, 04:16 PM
insertAdjactentHTML is not a W3C method, but a Microsoft proprietary extension. I wouldn't recommend using it for anything that the W3C DOM can do.
The problem you are having, is because an element created in one document isn't part of another document - you either have to create it in/from the document you want, or import it into the document. Creating it in the document is easiest: Use document.getElementById([string IdOfIFrame]).contentDocument instead of document. Only note that some browsers use .document instead of .contentDocument. You can also use the DOM0 way of referencing it through window.frames. The same difference between W3C and de facto standards exist here, too, but the de facto way works in all cases I've seen.
The other way is to use document.importNode, and then append the nodes where you want them. Have a look at W3C [DOM1], [DOM2 Core] and [DOM2 HTML] specs, or have a look at the Gecko DOM Reference. (link list available from my sig.)
05-07-2003, 04:31 PM
Maybe write a DOM implementation of insertAdjacentInnerHTML function. I think I have it at home. I'll have to check in a few hours.
What did you mean some HTML 'from' the main page? Arbitrary HTML string I suppose.
Yours is here: