Changing Page Layout

J

June Moore

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..
 
L

Lasse Reichstein Nielsen

June Moore said:
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
 
Y

Yann-Erwan Perio

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.
 
M

Michael Winter

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top