In IE5 and above, and Netscape 6 browsers, you can now specify where page breaks will occur when
the user prints a page.
This is done using Javascript and style sheets. Decide on the tag you wish to use as a page break.
This might be <h2> or <p> or indeed any standard HTML tag.
You then simply set the style for this tag to accept a page break in the following way:
<style>
h1{
page-break-after: always;
}
</style>
|
|
|
This will create a page break, immediately after the occurence of any <H1> tag.
The following will do the same, but break before the before:
<style>
h1{
page-break-before: always;
}
</style>
|
|
|
You can set the page-break-after and page-break-before attributes to auto if you wish to only
insert a page break if naturally at the end of a page, or you can cancel the operation completely by
setting the tag to ''.
To turn on all H1 elements in a document you can use something like the following:
<script language="javascript">
for (i=0; i<document.getElementsByTagName("H2").length;i++)
document.getElementsByTagName("H1")[i].style.pageBreakBefore="always"
}
</style>
|
|
|
|
Useful Links

|
|