Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Client Create Dynamic Window/HTML

Reply
Thread Tools

Client Create Dynamic Window/HTML

 
 
MC
Guest
Posts: n/a
 
      08-09-2011
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. I can't seem to find an example of how to do
that. Does anyone know how or have a link to a reference?

Thank you,
MC


 
Reply With Quote
 
 
 
 
Tim Streater
Guest
Posts: n/a
 
      08-09-2011
In article <d2c3b$4e4198e5$4b58d23d$(E-Mail Removed)>,
"MC" <mica[removethis]@aisus.com> wrote:

> 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. I can't seem to find an example of how to do
> that. Does anyone know how or have a link to a reference?


What sort of content? If you have an element in the original window that
you'd like your new window to have access to, then something like:

ptr = opener.document.getElementById("id-of-element");

gets you a pointer to it.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
 
 
 
MC
Guest
Posts: n/a
 
      08-09-2011
Ok, this will create a document with two childNodes
(0) document type
(1) html element

var doctype = document.implementation.createDocumentType('html',
'-//W3C//DTD HTML 4.01 Transitional//EN',
'http://www.w3.org/TR/html4/loose.dtd');
var doc = document.implementation.createDocument('', 'html', doctype);

How do I open a window using this or can I?

MC
PS, window.open(doc) opens but it does not use doc


 
Reply With Quote
 
MC
Guest
Posts: n/a
 
      08-10-2011
I don't care about the content...I need to use js to open a window with a
doctype tag. window.open does not do that.

MC


 
Reply With Quote
 
MC
Guest
Posts: n/a
 
      08-10-2011
This works but has no doctype tag:

var winProposal = window.open("", "Quote Proposal",
"status=1,width=600,height=800");
var nodeHTML = {};
var nodeHEAD = {};
var nodeBODY = {};
for (var i=0; i < winProposal.document.childNodes.length; i++) {
if (winProposal.document.childNodes[i].nodeType == 1) nodeHTML =
winProposal.document.childNodes[i];
}
for (var i=0; i < nodeHTML.childNodes.length; i++) {
if (nodeHTML.childNodes[i].nodeName == 'HEAD') nodeHEAD =
nodeHTML.childNodes[i];
if (nodeHTML.childNodes[i].nodeName == 'BODY') nodeBODY =
nodeHTML.childNodes[i];
}


nodeBODY.innerHTML = "some junk here";

Is there a better way? I would really like to create the html, populate a
document object, then open the window and display it.

MC



 
Reply With Quote
 
MC
Guest
Posts: n/a
 
      08-12-2011
Wow,
Seems as if I have stumped the masters...


 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-12-2011
wrote:

> Wow,
> Seems as if I have stumped the masters...


That is a fallacy.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
 
Reply With Quote
 
MC
Guest
Posts: n/a
 
      08-12-2011
What?
That your stumped or your a master? drumroll....


 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      08-12-2011
"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'

 
Reply With Quote
 
MC
Guest
Posts: n/a
 
      08-12-2011

"Lasse Reichstein Nielsen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plz help....Create Dynamic Client Class with Information Provided by WSDL webServiceHelp Java 0 11-28-2006 01:24 PM
Create Dynamic Client Class with Information Provided by WSDL webServiceHelp Java 0 11-27-2006 09:42 AM
How to create a client activated remoting object in an MFC Client Max-Ph. Blickenstorfer ASP .Net 2 01-29-2004 04:54 PM
VPN between 2 Cisco routers (1 static, 1 dynamic) with access from stat --> dynamic over ISDN Hans-Peter Walter Cisco 3 01-21-2004 02:12 PM
Does Pix or cisco router support dynamic-to-dynamic IPSec VPN? c Cisco 2 01-13-2004 01:53 AM



Advertisments