Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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();
        }
Reply With Quote
  #2 (permalink)  
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)
Reply With Quote
  #3 (permalink)  
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!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:43 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.