Trying to print() one frame from another

S

Scott Navarre

Hello,

I have 2 frames. The top one is the control frame and the bottom one is
the display. I have a roll-over button in the top frame that I want to use
to do a print() for the bottom frame.
I tried having this JavaScript code when the roll-over button is clicked:
parent.frames[1].focus();parent.frames[1].print()

I am using Internet Explorer on Windows, and I am getting a print window
with "Only the selected frame" selected. But when I click the "OK" button
to tell Windows to print, it prints the top frame instead of the bottom
one...

I also tried putting this function in the header of the bottom frame, and
then calling it from the top frame:
function FramePrint()
{
self.print()
}

But it still likes to print the top frame...

Thanks,
Scott Navarre
 
R

Ron Barnett

Scott Navarre said:
I have 2 frames. The top one is the control frame and the bottom one is
the display.
I'm doing a similar thing on a project i'm working on
I am using Internet Explorer on Windows,
yep same here,
But it still likes to print the top frame...
Hmm, I get the same results, but I also tried on Mozilla,
Guess what, it worked like it should, bottom frame printed nicely.

The problem looks like another Microsoft 'feature'
(standards ? what stsndards?)

My resort - a bit messy, is to place a button on the page to be
printed and 'hide'it from the printer with css. If you detect a
compliant browser you can hide the button fully, or just don't being
display in the first place.

Have you made any progress ?

I'm going to try the Microsoft site.

Cheers

Ron.
 
D

DJ WIce

: I tried having this JavaScript code when the roll-over button is
clicked:
: parent.frames[1].focus();parent.frames[1].print()

I have an iframe on my main page.
I use parent.window.print(); from the iframe.
That works in MSIE and NN/Moz.

: I am using Internet Explorer on Windows, and I am getting a print window
: with "Only the selected frame" selected. But when I click the "OK" button
: to tell Windows to print, it prints the top frame instead of the bottom
: one...

Maybe you want to open a new window with the frame and print that one?
Look at some lyric sites, they have print buttons for frame printing too.

Wouter
 
D

DJ WIce

function PrintMain()
{

document.getElementById('contenxtmenu').style.setAttribute('display','none')
;
if (document.all)
document.body.focus();
window.print();

document.getElementById('contenxtmenu').style.setAttribute('display','block'
);
}

Will print only the mainpage in my case.. when the childframe calls
parent.PrintMain(); So the body is focused instead of the frame..

So frame[1].body.focus() might do the trick in your case?

Wouter
 
D

DJ WIce

:
document.getElementById('contenxtmenu').style.setAttribute('display','none')

replaced by
document.getElementById('contenxtmenu').style.display='none';

NN/Moz gives it's OK too.
IE5+ needs a document.body.focus(); of the frame that needs to be printed.

Wouter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top