Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 1 changed file with 10 additions and 1 deletion. Show diff stats Hide diff stats

  1. +10 1 js/emphasis-src.js
11 js/emphasis-src.js
@@ -71,7 +71,16 @@ var Emphasis = {
71 71 addCSS: function() {
72 72 /* Inject the minimum styles rules required */
73 73 var st = document.createElement('style');
74   - 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; }';
  74 + st.setAttribute('type', 'text/css');
  75 + /* for validation goodness */
  76 + 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; }';
  77 + try {
  78 + /* try the sensible way */
  79 + st.innerHTML = stStr;
  80 + } catch(e) {
  81 + /* IE's way */
  82 + st.styleSheet.cssText = stStr;
  83 + }
75 84 document.getElementsByTagName("head")[0].appendChild(st);
76 85 },
77 86

0 comments on commit dcb5fca

Please sign in to comment.
Something went wrong with that request. Please try again.