Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to print the all child pages of frameset?

Posted on 2002-05-30
7
Medium Priority
?
277 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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

916 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