not working Windows 8 / 8.1

2019-06-23 22:57发布

问题:

Windows 8/8.1 (Initially problem appeared in 8 so I upgraded to 8.1, but problem persists)

IE 11.0.2

I'm using a product called eTools. It is used to generate and manage character sheets for Dungeons and Dragons gaming. The information is stored in a database file, but to create a character sheet the software uses XLS stylesheets to generate a HTML file. A script then opens the HTML file in IE and initiates the Print command. The user then selects the printer and clicks OK.

The problem is that the following line gets ignored:

<br style="page-break-after: always">

I'm pretty sure that this line is the culprit because if I save the HTML file and print it on a PC with an older version of Windows and IE it works fine.

I have tested various printers, including Adobe PDF printer and all fail on Windows 8/8.1 but work on an older version.

The product works fine on Windows XP, Vista and 7, but it has a problem on Windows 8 and 8.1 x64.

I'm wondering if there is a setting in Windows 8/8.1 or IE11 that I've overlooked?


Edit:

I just took the HTML file created in Windows 8.1 and IE11 and tried to print it on Windows Vista with IE9. It printed fine.

This leads me to think that there is something about IE11 that is causing it to ignore the page-break tags.

Can anyone help me with this?

回答1:

According to http://www.javascriptkit.com/dhtmltutors/pagebreak.shtml the problem may be with using the <br /> element:

Note that page-break-after may not work with <BR> or <HR> tag in some browsers.

Instead, they suggest trying this:

<DIV style="page-break-after:always"></DIV>

Using a div worked nicely for me; hope it helps someone else too.



回答2:

Ran into the same issue today in ie11. ie has a couple issues. first it doesn't like the page break inside a <br> but will work fine in a <div> or <p> tag. It then only seems to work if I have content after the page break tag.

like this:

<div style="page-break-after: always;"></div>
<div></div>

This does not work:

<div style="page-break-after: always;"></div>

Unfortunately this creates a blank page at the end every time but I haven't any other way to make it work without it.



回答3:

page-break-after doesn't work with a
tag. Try a p or br tag

<p style="page-break-before: always">&nbsp;</p>