Cannot get FlowType.js to work

流过昼夜 提交于 2019-12-25 02:46:10

问题


I've inserted the following right before the </body> tag and the type isn't changing at all. I can't figure out what I'm doing wrong.

https://github.com/simplefocus/FlowType.JS

http://jsfiddle.net/tawshmcd/gLJxE/

--

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>  
<script src="https://raw.github.com/simplefocus/FlowType.JS/master/flowtype.js"></script>

<script>
    $('body').flowtype({
     minimum   : 500,
     maximum   : 1200,
     minFont   : 12,
     maxFont   : 40,
     fontRatio : 30,
     lineRatio : 1.45
    });
</script>

回答1:


Short answer: Don't src from raw.github.com.

The problem is that you're sourcing the flowtype.js file from github raw. Github raw returns javascript as type plaintext (to discourage sourcing from github raw).

Since the file has the wrong mimetype, the webbrowser won't execute it as javascript.

To fix the problem you will need to find a proper host for the file. You can host it yourself via a local webserver, or find a free CDN account to put the file up.

Edit to add:

With your JS Fiddle, if you open the Javascript console, you'll see the following error:

Refused to execute script from 'https://raw.github.com/simplefocus/FlowType.JS/master/flowtype.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.



来源:https://stackoverflow.com/questions/20356231/cannot-get-flowtype-js-to-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!