Solved

How to print the all child pages of frameset?

Posted on 2002-05-30
7
272 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What does GoogleTagMgr javascripts below do 5 36
Adding Row and Cell on a table 14 25
I have a few questions about using the Google Developer's Console. 4 41
Html Newline 7 21
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…
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…

830 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