Solved

How to print the all child pages of frameset?

Posted on 2002-05-30
7
271 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
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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

821 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