16
我希望能够让用户选择他们希望显示页面的字体。Here是Google建议您使用JavaScript进行操作的方式。在页面加载后动态加载谷歌字体
WebFontConfig = {
google: {
families: ['Tangerine', 'Cantarell']
}
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
我该如何修改它以便在页面加载后重新获得字体?
完美多谢 – Alexis
请务必使用在生产中的特定版本。否则不会有缓存。 – sanmai
@sanmai:那不是真的......有最新版本的缓存长达1年。我认为这个问题更多的是一个buggy版本会打破你的网站。 –