Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 3rd, 2005, 01:13 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default javascript: window.open & document.documentElement

Hello All,

Problem:

I'm having problems addressing a new declared window innerHTML object. I have no problems addressing window.document.documentElement.innerHTML.

Solution:

To be able to address pp.document.documentElement.innerHTML...
What am I doing wrong?

--Thanks


--- Doesn't work (Note: see variable str) ---

function getPrintPage() {
            var pp = window.open("",null);
            var str = ""
            pp.location = "page.aspx?<%= request.querystring %>&amp;act=print";
            pp.document.open();
            str = pp.document.documentElement.innerHTML;
            pp.document.write('<P>' +str+ '</P>');
            pp.document.close();
            pp.print();
            pp.close();
        }




--- Works but not the desired result (Note: see variable str) ---

function getPrintPage() {
            var pp = window.open("",null);
            var str = ""
            pp.location = "page.aspx?<%= request.querystring %>&amp;act=print";
            pp.document.open();
            str = document.documentElement.innerHTML;
            pp.document.write('<P>' +str+ '</P>');
            pp.document.close();
            pp.print();
            pp.close();
        }
 
Old February 3rd, 2005, 06:10 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You don't need to open the document to read the innerHTML. Two things to watch out for, firstly if the page in the child window is in a different domain you will not be able to read the html, secondly it maybe that the page hasn't finished loading when you try to read it. Try a loop:
Code:
while (pp.document.readyState != "complete")
{
  //
}
//Document is ready

--

Joe (Microsoft MVP - XML)
 
Old February 3rd, 2005, 04:36 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Err,This document already has DocumentElement node ismailc XSLT 5 December 24th, 2007 12:40 PM
New window not being open by javascript akhilesh_g Classic ASP Professional 1 September 14th, 2007 04:13 AM
JavaScript : window.open -> Popup Blocker Issue AbrarNazeer Pro JSP 0 September 2nd, 2006 05:49 AM
document.DocumentElement.RemoveChild Error jrbancroft C# 2005 2 August 7th, 2006 10:36 PM
getURL with javascript window.open properties nancy Flash (all versions) 9 June 4th, 2005 07:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.