From c080e1b830741432ae397f6098470b132a76a6af Mon Sep 17 00:00:00 2001 From: Jason Johnston Date: Wed, 8 Feb 2012 20:35:55 -0700 Subject: [PATCH] Fix printing error in IE9 by putting the print media check before attempting to access window.PIE --- sources/htc_script.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sources/htc_script.js b/sources/htc_script.js index 9e54761..cc0b15d 100644 --- a/sources/htc_script.js +++ b/sources/htc_script.js @@ -72,16 +72,20 @@ if ( !window[ 'PIE' ] && docMode < 10 ) { } function init() { - var PIE = window[ 'PIE' ]; - if( PIE && doc.media !== 'print' ) { // IE strangely attaches a second copy of the behavior to elements when printing - PIE[ 'attach' ]( el ); + if ( doc.media !== 'print' ) { // IE strangely attaches a second copy of the behavior to elements when printing + var PIE = window[ 'PIE' ]; + if( PIE ) { + PIE[ 'attach' ]( el ); + } } } function cleanup() { - var PIE = window[ 'PIE' ]; - if ( PIE && doc.media !== 'print' ) { - PIE[ 'detach' ]( el ); + if ( doc.media !== 'print' ) { + var PIE = window[ 'PIE' ]; + if ( PIE ) { + PIE[ 'detach' ]( el ); + } } el = 0; }