javascript - Dynamically load google fonts after page has loaded -


i able have user select font page displayed in. here way google recommends using 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);       })(); 

how can modify can re-get fonts after page has loaded?

check out webfont.load command in github repo:

https://github.com/typekit/webfontloader

you can load whatever font want dynamically:

 <script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>    <script>          webfont.load({                     google: {                             families: ['droid sans', 'droid serif']                       }           });     </script> 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -