"Lasse Reichstein Nielsen" <> wrote in message
news:...
> "MC" <mica[removethis]@aisus.com> writes:
>
>> Doing the following will open a new window and get a page:
>> window.open('/mypage.html'...
>
>> I would like to open a new window but fill it with dynamic content from
>> the
>> client current window DOM.
>
> So, you need to copy the DOM to a different document.
> That takes extra work, since DOM elements always belong to the document
> that
> created them. I.e., you need to mirror the content in the other window.
>
> For that you can use document.importNode.
>
> You definitly need the other window to be loaded before you can start
> doing anything. I would open it as:
>
>
> window.open('javascript:"<body><script>document.bo dy.appendChild(document.importNode(opener.document .getElementById(\'id_of_element_to_copy\'),
> true))</script></body>"')
>
> Ofcourse, that uses standard DOM features, so it won't work in IE.
>
> Alternatively, you could just get the innerHTML containing the content
> you want to move, and add it as innerHTML in the receiving page.
>
>> I can't seem to find an example of how to do
>> that. Does anyone know how or have a link to a reference?
>
> Why take content from the DOM of the opening page instead of just taking
> some data that can be used to build a DOM on both pages. I.e., separate
> your data model from your display technology, and only reuse the data.
>
> /L
> --
> Lasse Reichstein Holst Nielsen
> 'Javascript frameworks is a disruptive technology'
>
I know how to manipulate and copy content, no problem. What I am trying to
do is load a document, then open it, instead of using the window.open, then
copying/filling the content. The content is coming from the DOM, and cloning
content. Its pretty neat, we are essentially creating a print report based
on screen content and DOM, without having to make a roundtrip to the server.
I take it from your comment that you think filling, then opening a document
is not possible?
Thanks MC
|