简体   繁体   中英

IE Printing changes absolute position

In internet explorer 6+, I am trying to make a mark on the left border where an element appears in the text. This currently works by putting an image at the absolute position with an X of 5px and a Y which is the absolute position of the element, worked out by navigating up the offsetParents and margins of all the parents up to the root.

This works fine on screen, everything is in the right place.

However, when I go to print it I have to use a template with a header and footer. Internet explorer deals with putting the headers and footers on the document and I never seem to have access to the file it has generated and prints.

Is there some way I can ensure these lines stay in place?

Stuff you do to the DOM after the page has loaded won't be reflected in the printed output. What you can do, or I should say, what you can try to do, is to create a new page in a popup window using Javascript. That way, you can create a new DOM in that new page that has whatever computed content you like. Then have the user choose to print that.

Now, that said, I suspect you'll still find that the control you have over the look of the printed version is very limited. Browsers have been making all sorts of progress (though you're talking about IE6 here, I realize) but printing remains quite primitive. On top of that, the very concept of absolute positioning gets a little funny when you're talking about paged media (ie, print).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM