Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

window.print() not printing whole page

6,064 views
Skip to first unread message

prabhjot singh

unread,
Oct 21, 2009, 12:09:43 PM10/21/09
to
I've a scrollable screen and I'm having a print button on it and
"window.print()" function is called on its onclick event.

My problem is it only prints the "viewable" part of the screen, not
the whole screen.If a page is scrollable, the print should extend to 2
(or more) pages if contents do not fit in 1 page. But in my case, it
always print only 1 page and rest of contents are not printed.

P.S. I'm using IE7 and it must work for IE7 atleast (for rest I'm not
bothered).

Martin Honnen

unread,
Oct 21, 2009, 12:29:23 PM10/21/09
to

window.print() only pops up the print dialog and then the user can set
print settings in that dialog. So check the print settings in that dialog.


--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/

prabhjot singh

unread,
Oct 22, 2009, 6:09:40 AM10/22/09
to

Hey Martin,

Ok, but the same print button works fine, when I embed my jsp in a
parent jsp as iframe. But the problem is I can't go with that approach
due to standard being followed in our project. That is why I'm sure it
has nothing to do with 'Printer settings' atleast.

Just to describe, on the screen I've got a table which is scrollable.
and print button is below that scrollable area. And the print button
just prints the 1st page and leave other contents as is.

VK

unread,
Oct 22, 2009, 6:28:18 AM10/22/09
to

window.print() method prints the frame/window that currently is having
the focus. So one option is that the main window has the focus and
being printed with the visible part of table's iframe in it. Try this:
function printIt() {
yourTableIframe.focus();
yourTableIframe.print();
}

Another option - if the first didn't help - is that someone screwed
things up with media-dependent CSS. Check all involved pages if they
have something like <link href="..." media="print"> and if so then
what is in there.

rf

unread,
Oct 22, 2009, 6:30:04 AM10/22/09
to

"prabhjot singh" <er.pra...@gmail.com> wrote in message
news:bdea3d3b-912d-40b8...@y28g2000prd.googlegroups.com...

> I've a scrollable screen and I'm having a print button on it and
> "window.print()" function is called on its onclick event.

Why? What is wrong with the browsers bult in print facility?

> My problem is it only prints the "viewable" part of the screen, not
> the whole screen.If a page is scrollable, the print should extend to 2
> (or more) pages if contents do not fit in 1 page. But in my case, it
> always print only 1 page and rest of contents are not printed.

Then your page is broken. What happens when you use the browsers built in
print facility?

You probably have <guess> scrollable divs </guess>.

URL? WIthout a URL any response you get will be only, as per above,
guesswork.

> P.S. I'm using IE7 and it must work for IE7 atleast (for rest I'm not
> bothered).

Sad.

This is, I suspect, an HTML problem and nothing to do with javascript.


rf

unread,
Oct 22, 2009, 6:40:32 AM10/22/09
to

Did the OP say anything about frames? No, not as far as I can see.

> So one option is that the main window has the focus and
> being printed with the visible part of table's iframe in it. Try this:
> function printIt() {
> yourTableIframe.focus();
> yourTableIframe.print();
> }

Geberish.

> Another option - if the first didn't help - is that someone
> screwed

Who? This is the OP's page. Who is this "someone" that has screwed with
his/her page?

> things up with media-dependent CSS. Check all involved pages if they
> have something like <link href="..." media="print"> and if so then
> what is in there.


As usual, more giberish.


VK

unread,
Oct 22, 2009, 7:43:57 AM10/22/09
to
rf" <r...@z.invalid> wrote:
> > So one option is that the main window has the focus and
> > being printed with the visible part of table's iframe in it. Try this:
> >  function printIt() {
> >   yourTableIframe.focus();
> >   yourTableIframe.print();
> >  }
>
> Geberish.

My little boy, you are not in the position to talk with me like that,
try a year later after the regular posting in here - then we'll see.
So far it is tolerated from some pointed ears only but at least they
spell it right.
You so far get on some scripting basics, for instance on the
definition of the active window and the active document the
window.print applies to.
A little exercise sample could be like:
<!DOCTYPE html>
<html>
<head>
<title>window.print</title>
</head>
<body>
<p onclick="window.frames[0].focus();window.frames[0].print();">print</
p>
<iframe src="someLongDocumentCausingScroll.html"></iframe>
</body>
</html>

First print it using "print" script. Next print it over File>Print.
Compare results, think why are so different.

> > Another option - if the first didn't help - is that someone
> > screwed
>
> Who? This is the OP's page. Who is this "someone" that has screwed with
> his/her page?

It is not necessary to be OP made table to print, OP maybe only is
including it into the interface he has made.

> > things up with media-dependent CSS. Check all involved pages if they
> > have something like <link href="..." media="print"> and if so then
> > what is in there.
>
> As usual, more giberish.

Again - you are too green yet to get bold on me.
After having finished with the window.print exercise continue with CSS
media types:
http://www.w3.org/TR/CSS2/media.html#media-types


SAM

unread,
Oct 22, 2009, 9:37:56 AM10/22/09
to
Le 10/22/09 12:09 PM, prabhjot singh a �crit :

>
> Just to describe, on the screen I've got a table which is scrollable.
> and print button is below that scrollable area. And the print button
> just prints the 1st page and leave other contents as is.


Make a print css with the rule overflow of the table (or this of its
container) set to none

something like :

@media print {
#table_container { overflow: none; }
}

--
sm

SAM

unread,
Oct 22, 2009, 9:50:51 AM10/22/09
to
Le 10/22/09 3:37 PM, SAM a �crit :

> Le 10/22/09 12:09 PM, prabhjot singh a �crit :
>>
>> Just to describe, on the screen I've got a table which is scrollable.

"a table wich is crollable" doesn't tell how that is made.

In fact, if I well understood, the table is in an iframe.
The VK's way seems to work (Firefox)

>> and print button is below that scrollable area. And the print button
>> just prints the 1st page and leave other contents as is.
>
>
> Make a print css with the rule overflow of the table (or this of its
> container) set to none

that applies only if the table is in a "scrollable" *DIV*
(not for an iframe, as I've seen that the table was there)

--
sm

0 new messages