Solved

How to print the all child pages of frameset?

Posted on 2002-05-30
7
273 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

732 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