如何用js获取系统字体

JavaScript08

如何用js获取系统字体,第1张

var defaultFont = 'getComputedSylte' in window?getComputedStyle(document.documentElement)['font-family']:document.documentElement.currentStyle['font-family']

//defaultFont的结果就是浏览器的默认字体名称。

如果你在html中定义了字体大小的话可以获取。通过document.getElementById('id').style.fontSize获取利用jquery $('id').css('fontSize')但是如果在html中没有定义字体大小的话没法获取。