Creating a new Explorer Window by passing HTML

C

Casper

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
 
A

Aaron Gray

Casper said:
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?

Something like :-

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

or some variation may possibly work.

Aaron
 
M

marss

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);
 
T

Thomas 'PointedEars' Lahn

Please provide attribution of quoted material.

<URL:http://jibbering.com/faq/faq_notes/pots1.html>
"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
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 4/28/2006 5:04 AM:
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.

Irrelevant to the post you replied to.
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:

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top