Skip to content

Instantly share code, notes, and snippets.

@Thibaut-B
Created April 14, 2013 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Thibaut-B/5383783 to your computer and use it in GitHub Desktop.
Save Thibaut-B/5383783 to your computer and use it in GitHub Desktop.
Font face icon for IE6 and 7
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' : '&#xe000;',
'icon-play' : '&#xe001;',
'icon-film' : '&#xe002;'
},
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