Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

IE8 and after print #58

dragosu opened this Issue Apr 11, 2012 · 6 comments


None yet
4 participants

dragosu commented Apr 11, 2012

I was getting a strange behaviour when using the print version (on a complex page with dynamic content scrolling - instead of page reload) I guess .. probably because of the page complexity, but after print preview in IE8 a blank page was show instead of the content. Sorry I cannot provide the page itself. But to make it 'work' I had to execute 'after print' code with a delay.

ownerWindow.attachEvent('onafterprint', function() {
  var fnc = function(){
    // remove wrappers, leaving the original elements, and remove the shived style sheet
   // my code >>
    if (_g_after_print)
    // << my code
  window.setTimeout(fnc, 500);

This was a quick 'fix', did not try to see why (and when) this can happen .. but it just worked for me.
I used there '_g_after_print' just to scroll the content to the right position as It was changed by the 'html5shiv' on the way.

This defect occurred for my website too. The line shivedSheet.removeNode(true) froze IE8. CPU usage went up to 100% and the webpage appeared blank and white.

Based on @dragosu's solution, I have placed that particular line in a setTimeout.

ownerWindow.attachEvent('onafterprint', function() {
  // remove wrappers, leaving the original elements, and remove the shived style sheet
  setTimeout(function() {
  }, 500);

aFarkas commented May 13, 2012

The setTimeout solution by @keeganstreet can also cause some problems, so I can't change the script to this. I really need a testcase. If one those pages is now online. I would like to have a link. (Even if you fixed it by changing the source of your html5shiv). You can also send me an email.

I can't share this particular website but I will try to recreate the defect separately.

@aFarkas I've been able to track this issue down to a crazy mix of things...

Please check this testcase: https://gist.github.com/2838269

Some notes:

  • The css file is inside a folder. If it's at the same level as the html file, I can't repro.
  • The nobile-webfont.eot file doesn't exist. If I create that file (just an empty file with that name), results were random for me (sometimes can repro, sometime can't)
  • This will only happen in native IE8. Not "IE9 in IE8 mode", and probably not in IE Collection either.

mrazzari commented Jun 1, 2012

FWIW, in case anyone needs an urgent fix for this, here's the minified version of @keeganstreet's workaround.

@aFarkas, it would be cool to know what kind of "some problems" you're referring to, so we can more actively look for them. The setTimeout fix seems to be working OK in our tests.


aFarkas commented Jun 4, 2012

Many thanks to all of you guys, especially for the testcase and for the code fix.

@aFarkas aFarkas closed this Jun 4, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment