|
|
|
date: Mon, 7 Jul 2008 10:50:11 -0700,
group: microsoft.public.inetsdk.programming.scripting.jscript
back
RE: Passing XML objects between windows
This is very interesting, and not quite what I expect (although I had a
feeling that something like this was happening).
As I understand it, cloneNode returns a new object. I would not expect that
the destruction of the object that created it would destroy it, as well.
This is why I clone it in the context of the parent window.
You are quite correct in your assumption that I have stripped out everything
that is not pertinent to this discussion so as not to complicate the code.
The application creates a list of documents that may be edited. It keeps
the XML for each in an array. It spawns a new window that is used to edit
the document. The XML is then returned to the parent window.
Unfotunately, in IE, if I want to add nodes in the edit window, I cannot
simply add them to the original XML, as it is out of context. Interestingly,
FF is perfectly happy to add nodes to the original using an xmlDoc that is
created in the context of the edit window.
I think the solution you suggest, namely to have the parent window create an
xmlDoc, will solve the problem. Thanks much.
/Joel Finkel
"Old Pedant" wrote:
> Seems pretty straightforward to me.
>
> Your code does:
> function StoreXml(p_index, p_xml)
> {
> try
> {
> g_XmlArray[p_index] = p_xml.cloneNode(true);
> }
>
> So the cloning is done *BY THE p_xml OBJECT* that was passed into this
> function.
>
> But *THAT* object is created in the popup via
> var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
> ...
> window.opener.StoreXml(index, xmlDoc.documentElement);
>
> so of course when the xmlDoc object from the popup gets destroyed, anything
> that it contains *OR THAT IT CREATED* will also get destroyed.
>
> I'm not clear why you are going around the long way to do this, but I assume
> that you are reproducing just the important parts of the problem (for which,
> thanks! else we'd likely never figure it out!). Seems to me like if you can
> do
> xml = window.opener.GetXml(index);
> that then instead of doing
> var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
> you could maybe add a method on the opener window that would return an
> object in *ITS* scope, so you'd do
> var xmlDoc = window.opener.getMeAnXmlDomObjectPlease( );
> and now it should work. No?
>
date: Tue, 8 Jul 2008 09:38:01 -0700
author: Joel Finkel
|
|