Solved

How to print the all child pages of frameset?

Posted on 2002-05-30
7
275 Views
Last Modified: 2008-02-01
I want to put a "print" button in a frameset that shown inside a showModelessDialog().
I call parent.window.print(), but it only prints the child page where the button located.
What is the solution?
0
Comment
Question by:galor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 7044211
You can only print ONE frame. To solve your problem you'd need to set focus to the frame you want to print.

For example if your contentframe is called "frContent" you would do:

top.frContent.focus();
window.print();

Please note that javascxript cannot be used to print all frames on your website.

CJ
0
 

Author Comment

by:galor
ID: 7044327
I think that i can print the all frameset child window by using <TEMPLATEPRINT> of IE5.5.
Do you have an example for that?
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7044376
I'm pretty surprised about that one. Thank you!

Here's a sample

<SCRIPT language="JScript">
function Init()
{
    switch (dialogArguments.__IE_PrintType)
    {
        case "Prompt":
            if (Printer.showPrintDialog())
                DoPrint();
            break;
        case "NoPrompt":
            DoPrint();
            break;
        case "Preview":
        default:
            break;
    }
}

function DoPrint()
{
    if (Layout1.contentDocument.readyState == "complete")
    {
        // This block will be called when printing with user prompt
        // because the Print and Preview dialog boxes give time for
        // the content document to complete loading
        PrintNow();
    }
    else
    {
        // This block will usually be called when printing without a user prompt.
        // It sets an event handler that listens for the loading of the content
        // document before printing. Sometimes, however, even without a user prompt,
        // the content document will be loaded in time for the previous
        // block to execute.
        Layout1.contentDocument.onreadystatechange = PrintWhenContentDocComplete;
    }
}

function PrintWhenContentDocComplete()
{
    if (Layout1.contentDocument.readyState == "complete")
    {
        Layout1.contentDocument.onreadystatechange = null;
        PrintNow();
    }
}

function PrintNow()
{
    firstPage = Printer.pageFrom;
    lastPage = Printer.pageTo;
   
    Printer.startDoc("A print job");
   
    for (i = firstPage; i <= lastPage; i++)
    {
        if (document.all("Page" + i))
            Printer.printPage("Page" + i);
        else
            alert("Print Error");
    }
           
    Printer.stopDoc();
}
</SCRIPT>
</HEAD>

<BODY onload="Init()">
<IE:TEMPLATEPRINTER ALLLINKEDDOCUMENTS id="Printer"/>

</BODY>
</HTML>
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:galor
ID: 7066339
I find the answer myslef.
I put a "Print" button in one of the frames which call: parent.DoPrint();
The DoPrint() in the frameset window looks like this:
function DoPrint()
{
        window.focus();
     window.print();
}

This selects the "All frames individually" in the Print dialog.
0
 

Expert Comment

by:wlawson
ID: 7227566
That one is correct... you can also loop through all of the Frames, which have unique indexes.

var iNumOfFrames = AllFrames.length
for (i=1; i < iNumOfFrames; i++) {
     AllFrames(i).focus()
     AllFrames(i).print()
}

I think the Indexes usually are top down and zero based. So if you put your Print button at the top you should print from 1 to the end.
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8263617
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ - REFUND
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 8322201
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question