I’m wondering about using the print option by using JavaScript in Firefox.
I have a page that has a print link:
<a href="javascript:print()">print</a>
I also have followed the instructions on About Javascript’s print button page.
The problem is that when I try to print a page under Firefox, I get a four page PDF preview with missing content:
- The first page is empty,
- The second will start with the content that should be on the third page, and
- The third and fourth pages are empty
I tried using Chrome, and it works as expected.
Any ideas?
The best way to get a consistent printing behaviour is using a print stylesheet. This defines exactly, which content should be printed how, because browsers differ strongly on that matter. Some browsers have problems with certain markup (e.g. floated elements).
You can find a very good article about print stylesheets on A List Apart that should be very helpful for you.
Certainly there might be other good articles which are newer but this ALA article is so fundamental that it still is worth reading even though it is 10 years old – which is like stoneage for web-content;)