Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / April 2006



Tip: Looking for answers? Try searching our database.

Creating a new Explorer Window by passing HTML

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Casper - 25 Apr 2006 20:43 GMT
I currently have this code:

<script language="javascript">
     function init()
     {
       // load XML source document
       var source = new ActiveXObject("Msxml2.DOMDocument.4.0");
       source.async = false;
       source.load("record49a36bde.xml");

       // load XSLT stylesheet document
       var stylesheet = new ActiveXObject("Msxml2.DOMDocument.4.0");
       stylesheet.async = false;
       stylesheet.load("detail_view.xsl");

       // transform the source using the XSLT stylesheet
       target.innerHTML = source.transformNode(stylesheet);
     }
   </script>

I then need to be able send the html stored in 'target' to a new
explorer window.

Is this possible?

Thanks
Aaron Gray - 27 Apr 2006 18:52 GMT
>I currently have this code:
>
[quoted text clipped - 20 lines]
>
> Is this possible?

Something like :-

       var newWindow = window.open();
       newWindow.document.innerHTML = target.innerHTML;

or some variation may possibly work.

Aaron
marss - 28 Apr 2006 09:22 GMT
>         var newWindow = window.open();
>         newWindow.document.innerHTML = target.innerHTML;

"document" doesn't nave "innerHTML" property, use "write()" method
instead of.

newWindow.document.write(target.innerHTML);
Thomas 'PointedEars' Lahn - 28 Apr 2006 10:04 GMT
>>         var newWindow = window.open();
>>         newWindow.document.innerHTML = target.innerHTML;

Please provide attribution of quoted material.

<URL:http://jibbering.com/faq/faq_notes/pots1.html>
<URL:http://www.safalra.com/special/googlegroupsreply/>

> "document" doesn't nave "innerHTML" property, use "write()" method
> instead of.
>
> newWindow.document.write(target.innerHTML);

It will not work, because the `innerHTML' property of any DOM object will
always only evaluate to the code of the content, not to the code of the
container.  Therefore, one has to write at least:

 var newWindow = window.open();
 if (newWindow && newWindow.document)
 {
   newWindow.document.open();
   newWindow.document.write(
       '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'
     + '  "http://www.w3.org/TR/html4/loose.dtd">'
     + '<html>'
     + target.innerHTML;
     + '<\/html>');
   newWindow.document.close();
 }

Since the `outerHTML' property has no broad support, there is an inevitable
loss of information to this approach.

PointedEars
Signature

There are two possibilities: Either we are alone in the
universe or we are not. Both are equally terrifying.
 -- Arthur C. Clarke

Randy Webb - 30 Apr 2006 06:24 GMT
Thomas 'PointedEars' Lahn said the following on 4/28/2006 5:04 AM:

>>>         var newWindow = window.open();
>>>         newWindow.document.innerHTML = target.innerHTML;
>
> Please provide attribution of quoted material.
>
> <URL:http://jibbering.com/faq/faq_notes/pots1.html>

Solid reference but at a minimum point a person to the relevant spot in
that document:

<URL: http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>

covers quoting/attributing.

> <URL:http://www.safalra.com/special/googlegroupsreply/>

Irrelevant to the post you replied to.

>> "document" doesn't nave "innerHTML" property, use "write()" method
>> instead of.
[quoted text clipped - 4 lines]
> always only evaluate to the code of the content, not to the code of the
> container.  Therefore, one has to write at least:

That does not, at a minimum, satisfy the needs.

>   var newWindow = window.open();
>   if (newWindow && newWindow.document)

No test to see if the window was closed by a popup blocker?

Nor does the code do anything with Symantec popup blocking code.

Signature

Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.