[thelist] Print in IE

.jeff jeff at members.evolt.org
Tue Feb 19 03:32:01 CST 2002


mark,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Mark Howells
>
> > there is.  you're going to kick yourself too -- it's
> > so simple.  it's the print() method.  tada!  it's
> > available as of ie5+.
>
> .... except for Mac. This is a royal pain in the bum if
> you want to add a "print me" button to a popped-up
> window with no toolbar, [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

which is part of the argument for not removing the toolbar or menubar from
popups to begin with, if you want the user to be able to print.  you
shouldn't be replacing browser functionality with scripting unless you're in
a controlled environment like an intranet.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> or if you want to provide a link to print just one frame
> from a frameset (parent.frames[0].document.print() or
> whatever).
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

well, with the syntax you provide you're going to have problems printing a
particular frame anyway.  you see, some browsers will execute the print()
method on the frame with focus.  that means you'd have to first call the
focus() method on the desired frame and then call the print() method on that
frame.  nevertheless, the fact that it doesn't work well is another good
reason to not use frames to begin with.

nonetheless, the solution i provided *does* work.  it calls the print()
method if the user agent supports it, otherwise it pops an alert() dialog
with instructions for the user.

the alternative would be to use document.write() to only write out the html
with the onclick event handler that calls the print() method if the user
agent supports the print() method to begin with.  that would mean no button
for non-js users or users with user agents that didn't support the print()
method.

that still brings us back to the issue of opening a new window containing a
document you expect them to be able to print but without the necessary
toolbar or menubar -- an issue i think you'll be hard-pressed to convince me
is necessary to encounter.

be kind to your users or they'll vote with their mouse.

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list