468,268 Members | 1,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

Changing Page Layout

Hi all,

Is there a way to use javascript to change a web page's default layout
e.g. change page orientation to landscape or portrait when the user
prints a copy of the webpage?

Thanks,
June..

Jul 23 '05 #1
3 3386
"June Moore" <ju******@yahoo.com.au> writes:
Is there a way to use javascript to change a web page's default layout
e.g. change page orientation to landscape or portrait when the user
prints a copy of the webpage?


The user decides whether to print in landscape or portrait mode,
usually in the print dialog, so all you can do is to make the *layout*
of the printed page work better with landscape or portrait mode.

To do that, you use a print stylesheet. It is inserted as:

<link rel="stylesheet" type="text/css" media="print" href="printstyle.css">

For details on how to write the stylesheet, you should ask in a CSS
group, e.g., comp.infosystems.www.authoring.stylesheets.

There is no need for Javascript for having different layout between
print and screen, CSS does that already.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
Lasse Reichstein Nielsen wrote:
Is there a way to use javascript to change a web page's default layout
e.g. change page orientation to landscape or portrait when the user
prints a copy of the webpage?
The user decides whether to print in landscape or portrait mode,
usually in the print dialog, so all you can do is to make the *layout*
of the printed page work better with landscape or portrait mode.


While this is true in effect, you should also be able to suggest
printing options, CSS2 had the "identified page" thing (I think it's
dead now), and CSS3 has the paged media module, which should permit

<style type="text/css">
@media print {
@page {
size:landscape;
}
}
</style>
<p>Hello, World</p>

Since I don't have a printer here, I cannot check whether this works,
but I wouldn't be surprised if your beloved Opera took this into account:-)
Regards,
Yep.
Jul 23 '05 #3
On 15/07/2005 12:31, Yann-Erwan Perio wrote:

[snip]
<style type="text/css">
@media print {
@page {
size:landscape;
}
}
</style>
<p>Hello, World</p>

Since I don't have a printer here, I cannot check whether this works,
but I wouldn't be surprised if your beloved Opera took this into account:-)


As far as I know, Opera is the only browser (at least among the usual
set) that implements paged media correctly.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.