Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding support for IE8 for setting <style> contents
  • Loading branch information
lindsayevans committed Apr 24, 2012
1 parent aef04f1 commit 981d6b0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions outline.js
Expand Up @@ -5,23 +5,28 @@
var style_element = d.createElement('STYLE'),
dom_events = 'addEventListener' in d,
add_event_listener = function(type, callback){
// Basic cross-browser event handling
if(dom_events){
d.addEventListener(type, callback);
}else{
d.attachEvent('on' + type, callback);
}
},
set_css = function(css_text){
// Handle setting of <style> element contents in IE8
!!style_element.styleSheet ? style_element.styleSheet.cssText = css_text : style_element.innerHTML = css_text;
}
;

d.getElementsByTagName('HEAD')[0].appendChild(style_element);

// Using mousedown instead of mouseover, so that previously focused elements don't lose focus ring on mouse move
add_event_listener('mousedown', function(){
style_element.innerHTML = 'a{outline:none}';
set_css('a { outline: none; }');
});

add_event_listener('keydown', function(){
style_element.innerHTML = '';
set_css('');
});

})(document);

0 comments on commit 981d6b0

Please sign in to comment.