Created
April 14, 2013 18:53
-
-
Save Thibaut-B/5383783 to your computer and use it in GitHub Desktop.
Font face icon for IE6 and 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function() { | |
function addIcon(el, entity) { | |
var html = el.innerHTML; | |
el.innerHTML = '<span style="font-family: \'fontName\'">' + entity + '</span>' + html; | |
} | |
var icons = { | |
'icon-newspaper' : '', | |
'icon-play' : '', | |
'icon-film' : '' | |
}, | |
els = document.getElementsByTagName('*'), | |
i, attr, html, c, el; | |
for (i = 0; ; i += 1) { | |
el = els[i]; | |
if(!el) { | |
break; | |
} | |
attr = el.getAttribute('data-icon'); | |
if (attr) { | |
addIcon(el, attr); | |
} | |
c = el.className; | |
c = c.match(/icon-[^\s'"]+/); | |
if (c && icons[c[0]]) { | |
addIcon(el, icons[c[0]]); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment