javascript - Media print css not working in IE11 print preview -


I have a page with CSS, to customize the print, I have some @ media print style in the same CSS file I work perfectly fine, but while printing, with IE 11, I realized that the preview works like media print style is not considered. If, on the other hand, I define a new CSS style and add it as a print stylesheet, even then the preview works fine (though it is applied to duplicate in many CSS styles defined in the CSS stylesheet I do not want to change in print).

I do not know if this can be of any help, but the way I print the page is by calling the Javascript function which only selects the content of my html page (#content ) And prints it (a copyright notice and logo are also added at the bottom of the printed page)

  function print () {var body = document .getElementById ('content ') InnerHTML. Var tmpWin = window.open ('', '', 'width = 640, height = 480'); TmpWin.document.open ("text / html"); TmpWin.document .write ("& lt; html> gt; and  gt;  "); TmpWin.document.close (); TmpWin.print (); TmpWin.close (); }  

Any ideas why I am having this problem?

Thank you

I saw your question, but without any answer I have IE 11 Using ExtJS 4.2.2, it was doing the same problem, and I could not find a solution for it easily.

It seems that IE 11 uses the entire page to make the window contents as context, not only the window, as expected, if you use print preview, you can Can check this behavior.

After doing a lot of excavation, after testing many tasks, I finally managed to get a working solution. In my case, what I had to do was to modify the printing script, as follows:

  & lt; Div id = "print" & gt; & Lt; Button type = "button" onclick = "document.exec comand ('print', wrong, empty);" & Gt; Print & lt; / Button & gt; & Lt; / Div & gt;  

In your case, the code below should work (instead of tmpWin.print ()):

  tmpWin.document.execCommand (' Print ', false, zero);  

As you can see, "document.execCommand" is used instead of the classic "window.print" function.

I know that it has been around this year for you, and I think that you are already doing this work. However, for the sake of the community, this is a solution I hope it helps anyone.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -