简体   繁体   English

无法使FlowType.js正常工作

[英]Cannot get FlowType.js to work

I've inserted the following right before the </body> tag and the type isn't changing at all. 我在</body>标记之前插入了以下内容,并且类型完全没有变化。 I can't figure out what I'm doing wrong. 我不知道我在做什么错。

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

http://jsfiddle.net/tawshmcd/gLJxE/ 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>

Short answer: Don't src from raw.github.com . 简短的答案: 不要从raw.github.com进行src

The problem is that you're sourcing the flowtype.js file from github raw. 问题是您要从github raw采购flowtype.js文件。 Github raw returns javascript as type plaintext (to discourage sourcing from github raw). Github raw将javascript返回为纯文本类型(以阻止从github raw采购)。

Since the file has the wrong mimetype, the webbrowser won't execute it as javascript. 由于文件的模仿类型错误,因此网络浏览器不会将其作为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. 您可以自己通过本地网络服务器托管它,也可以找到一个免费的CDN帐户来放置该文件。

Edit to add: 编辑添加:

With your JS Fiddle, if you open the Javascript console, you'll see the following error: 使用JS Fiddle,如果您打开Javascript控制台,则会看到以下错误:

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://raw.github.com/simplefocus/FlowType.JS/master/flowtype.js ”执行脚本,因为其MIME类型(“ text / plain”)不可执行,并且启用了严格的MIME类型检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM