[Javascript] Re: How to modify the browsers page setup parameters like orientation and margins?

William T. Simmons tsimmons at employmentlawadvisors.com
Fri Jan 17 09:52:09 CST 2003


Ed,
As Cutter noted, the actual language involved in Microsoft's IE-specific
DHTML is JScript. Microsoft's "DHTML Reference and SDK" is replete with
references to that language. The following link in the MSDN DHTML Reference
might help if you're trying to adjust a displayed page's attributes just for
printing purposes (warning - all these links will probably be munged):
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/ref
erence/events/onbeforeprint.asp

It discusses the IE-specific "onbeforeprint" event, which can be used in
conjunction with custom JScript or JavaScript "to modify the document just
before it prints or previews for printing. In most cases it is used to make
all the information on the page visible just before printing." If you have
the book, it's on page 991. That's only a small piece of what you're trying
to do (or maybe not a piece at all!), though, so you'd want to look
further - see below.

You'll find more information in that same reference guide in the topic on
"Scripting Support for Web Page Printing Sample":
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnscrpt/htm
l/dhtmlprint_samplecode.asp

It shows how, in Microsoft's words, "DHTML/JScript" can be used to
facilitate printing of a page from a browser. It's useful background, but
you'll probably want to read the topic "Beyond Print Preview: Print
Customization for Internet Explorer 5.5" (MSDN: Web Development >
Programming and Reusing the Browser > Print Templates > Overviews /
Tutorials". It looks like it really gets down to what you're trying to do
with saving the user some trouble with respect to the print setup for a
particular page.

For access to the actual Print dialog, the following link might help:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/
printpreview/reference/behaviors/templateprinter.asp

It describes advanced methods for accessing "page setup and printer settings
and control over print jobs" - useful links to more detailed topics appear
at the bottom - particularly useful might be the "dialogArguments" link
there.

Good luck in your continued research - if you find an ultimate solution, I
hope you'll post it in this forum - a lot of the participants here would
probably be interested in hearing about that.

HTH,
Tommy Simmons
Employment Law Advisory Network
www.employmentlawadvisors.com

----- Original Message -----
From: <eklinger at sunterra.com>
To: <javascript at LaTech.edu>
Sent: Thursday, January 16, 2003 3:41 PM
Subject: [Javascript] Re: How to modify the browsers page setup parameters
like orientation and margins?


> Thanks.  I was able to get to the link.  I will check it out.  I was
> hoping there would be a straight forward solution for this but it
> looks like it is turnning into a research project.  Oh well.
>
> Thanks again
>
> Ed
>
> --- In javascript at yahoogroups.com, "William T. Simmons"
> <tsimmons at e...> wrote:
> > Ed,
> > This is almost certainly one of those things that would have to be
> done via
> > IE-specific DHTML. The best place to start looking would be in the
> DHTML SDK
> > Reference section of the MSDN site:
> > http://msdn.microsoft.com/library/default.asp?
> url=/workshop/author/dhtml/ref
> > erence/dhtmlrefs.asp
> >
> > I hope that URL doesn't come through munged. Anyway, although I
> haven't done
> > the exact thing you're talking about, I've got the hard copy
> equivalent to
> > the above resource and remember seeing it when researching
> something else. I
> > wish I could help in a more specific way. Good luck!
> >
> > Tommy Simmons
> > Employment Law Advisory Network
> > www.employmentlawadvisors.com
> >
> > ----- Original Message -----
> > From: "Klinger, Edwin" <EKlinger at S...>
> > To: <javascript at L...>
> > Sent: Thursday, January 16, 2003 1:18 PM
> > Subject: [Javascript] How to modify the browsers page setup
> parameters like
> > orientation and margins?
> >
> > > Hello,
> > >
> > > I'm looking for a way in JavaScript to be able to set the
> > > browsers "Page Setup" properties. I'm specifically talking about
> IE
> > > 5+.
> > >
> > > I would like to be able to set the page orientation and margins.
> This
> > > is needed for printing purposes and not for displaying the page in
> > > the browser.
> > >
> > > I have a wide table that is about 900 in width that I need to
> print in
> > > landscape and adjust the browsers margins to fit this table on the
> > > paper. I will be opening a new window for printing this table
> using
> > > the window.open()method.
> > >
> > > I would like to set these properties myself and not have the user
> > > fiddle with them. Is this possible? Any other suggestions if not?
> > >
> > > Thanks for any help,
> > >
> > > Ed Klinger





More information about the Javascript mailing list