View Full Version : JS print() method
thody
04-25-2003, 04:12 PM
Hey, has anyone experienced bugs with the JS print() method? I've been receiving reports that it's not working in IE6 on win XP. I haven't had any trouble with it, but they're claiming the browser crashes.
Here's a sample http://www.lrg.com/contact_us.html, click the print icon next to the menu.
Thanks in advance
beetle
04-25-2003, 04:30 PM
Odd
The full statement is window.print(), but I'm not sure that would make a difference. perhaps try this
<a href="javascript://" onclick="window.print();return false;">Print</a>
thody
04-25-2003, 04:34 PM
Didn't work for you either? I've had no troubles in IE6 with XP, very odd. I don't think the window.print() or print() should matter...I'll try it though.
Weirdness!
beetle
04-25-2003, 04:36 PM
No, it actually works for me, I just don't know what's causing that.
Is it IE w/SP1 (6.0.2800) or w/o (6.0.2600) ?
thody
04-25-2003, 04:39 PM
I'm not sure, it's been relayed to me through the grapevine. I'd be surprised if that's what's the matter though, the print() method has been around for ages.
thody
04-29-2003, 03:16 PM
Hmm new development....I figured out it's not a javascript problem. The error occurs when trying to print pages that are more than 1 print page.
For example: http://www.lrg.com/financial_notes.html
I'm guessing this is a style sheet issue...any suggestions?
beetle
04-29-2003, 03:22 PM
More than 1 print page? What do you mean?
I don't see how the media stylesheets would cause a problem. Besides, that page you linked me to works just fine.
I think you need to contact your grapevine and get some more info. Exactly how does it "not work"
thody
04-29-2003, 03:30 PM
Well, this is no longer through the grapevine, this is what I uncovered after playing around with it for a while. It's affecting my machine (WinXP, IE6) as well.
By more than one print page, I mean that when it's printed it takes more than one piece of paper to print off the web page.
I've tried printing off each web page on the site, and they all work if the web page can be printed off on one sheet of paper. As soon as there's a page break, the browser freezes, and I get a fatal error. This occurs when going to print preview, and when printing, which leads me to believe it might have something to do with parsing the media style sheet. My earlier impression was that it was crashing at the print dialog, but it's actually when you go to print, or print preview.
beetle
04-29-2003, 03:49 PM
Well, then I guess you should remove all the stylesheets and see if it still errors -- or the print-stylesheet at least
(Note: I did see one stylesheet with no media specified)
thody
04-29-2003, 04:26 PM
I commented out the print style sheet, and the page prints fine, I just lose all the formatting, obviously.
The style sheet is very simple though, so I can't imagine what's causing the problem.
#content {
position: absolute;
visibility: visible;
top:100px;
left:65px;
}
#frame {
visibility: hidden;
}
#foot {
position:absolute;
visibility: visible;
bottom: 0px;
width: 588px;
}
#headImage {
position:relative;
visibility: visible;
}
#title{
position:absolute;
visibility: visible;
top:0px;
left:0px;
}
I guess the best approach is to eliminate definitions one-by-one until I find the culprit.
beetle
04-29-2003, 04:29 PM
Visibility? Use display instead
#frame {
display: none;
}
also, there's no reason to use
visibility: visible;
for the rest, by default they will be visible.
thody
04-29-2003, 04:42 PM
Hmm, well I had isolated the problem to the #frame definition, and your suggestion stopped the browser from crashing.
However, now I have a nesting issue, because the #content layer won't render in print preview.
I wanted to stay away from css-p so I used nested <div>s, and I believe the display: none; definition is over-riding the visibility: visible; definition in the #content definition.
I wonder if the z-index would help...
thody
04-29-2003, 04:49 PM
Nope.
thody
04-29-2003, 04:51 PM
Originally posted by beetle
by default they will be visible.
Default is inherit, and since they're nested I had to specify visible.
thody
04-29-2003, 05:00 PM
Upon further inspection, it's not the #frame definition, it's the #content definition. Hiding the #frame, simply hid the #content as well, which appeared to have fixed it, but the #content is the root of the problem.
Grr...
beetle
04-29-2003, 05:03 PM
Well, you may have some problems with your CSS because your HTML is invalid
<tr>
<td colspan="3" valign="top"><img src="images/blank_sidebar.gif" alt="" width="128" height="305" /></td>
<td colspan="10" rowspan="2" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><img src="images/left_arc.gif" alt="" width="21" height="18" /></td>
<td align="right" valign="top"><img src="images/right_arc.gif" alt="" width="18" height="16" /></td>
</tr>
</table>This is the first one I found, there may be more. Mozilla's DOM inspector doesn't even see div#content because of this error right here.
thody
04-29-2003, 05:08 PM
Wow. I wonder why w3.org didn't pick that up...must have made a change since I checked the HTML. It's not showing up in Dreamweaver either. Wierd...
I think I'm close to fixing it anyway though...I changed the position to relative, and am re-adjusting the co-ordinates and it is no longer crashing.
Thanks for the heads up on the HTML though. :eek:
thody
04-29-2003, 05:11 PM
Actually, wait a sec, I think that code is ok. I think you might have missed the <table> tag that didn't get bumped down to the next line. I think that code is legit.
thody
04-29-2003, 05:30 PM
Ok, so here's the latest... I'm sorry for all the mayhem guys.
I stopped the browser from crashing by changing the position from absolute to relative (don't ask me why that did it), and now the first page looks great.
However, if you go to page two of the print preview, the top part of the page is cut off. I believe it's the same section of the page that the #frame would cover if it were there. So it's masking it somehow.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.