Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for IE "Unknown runtime error"

Bug exists in both original NYTimes Emphasis and robflaherty's jQuery-ized Emphasis code.
  • Loading branch information...
commit dcb5fcac28b74420dab23510ae32e0b78ad8afc3 1 parent 7999d05
lirenzhu lirenzhu authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 js/emphasis-src.js
11 js/emphasis-src.js
View
@@ -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);
},
Please sign in to comment.
Something went wrong with that request. Please try again.