Skip to content

Commit

Permalink
Fix for IE "Unknown runtime error"
Browse files Browse the repository at this point in the history
Bug exists in both original NYTimes Emphasis and robflaherty's jQuery-ized Emphasis code.
  • Loading branch information
lirenzhu committed May 5, 2011
1 parent 7999d05 commit dcb5fca
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/emphasis-src.js
Expand Up @@ -71,7 +71,16 @@ var Emphasis = {
addCSS: function() {
/* Inject the minimum styles rules required */
var st = document.createElement('style');
st.innerHTML = 'p.' + this.classActive + ' span { background-color:#f2f4f5; } p span.' + this.classHighlight + ' { background-color:#fff0b3; } span.' + this.classInfo + ' { position:absolute; margin:-1px 0px 0px -8px; padding:0; font-size:10px; background-color: transparent !important} span.' + this.classInfo + ' a { text-decoration: none; } a.' + this.classActiveAnchor + ' { color: #000; font-size: 11px; }';
st.setAttribute('type', 'text/css');
/* for validation goodness */
var stStr = 'p.' + this.classActive + ' span { background-color:#f2f4f5; } p span.' + this.classHighlight + ' { background-color:#fff0b3; } span.' + this.classInfo + ' { position:absolute; margin:-1px 0px 0px -8px; padding:0; font-size:10px; background-color: transparent !important} span.' + this.classInfo + ' a { text-decoration: none; } a.' + this.classActiveAnchor + ' { color: #000; font-size: 11px; }';
try {
/* try the sensible way */
st.innerHTML = stStr;
} catch(e) {
/* IE's way */
st.styleSheet.cssText = stStr;
}
document.getElementsByTagName("head")[0].appendChild(st);
},

Expand Down

0 comments on commit dcb5fca

Please sign in to comment.