我正在动态地使用JS添加一个font-face,它适用于除Firefox之外的所有浏览器。
任何想法为什么?
function fontFace (className){
// var secondClassNameFont = className.charAt(className.length - 1)
// var secondClassName = className.substring(0, str.length - 1)
// secondClassName = secondClassName + parseInt(secondClassNameFont) + 1
// console.log(secondClassName)
// console.log(className )
var newStyle = document.createElement('style');
newStyle.appendChild(document.createTextNode("\
@font-face {\
font-family: '" + className + "';\
src: url('./css/fonts/compressed/eot/" + className + ".eot?#iefix') format(embedded-opentype),\
url('./css/fonts/woff/" + className + ".woff') format(woff),\
url('./css/fonts/ttf/" + className + ".ttf') format(truetype),\
url('./css/fonts/compressed/svg/" + className + ".svg#') format(svg);\
}\
." + className + "{\
font-family: '" + className + "';\
}\
"));
document.head.appendChild(newStyle);
// console.log(className)
}