【问题标题】:Cufon console error, not replacing font. (ReferenceError: Can't find variable: Cufon)Cufon 控制台错误,不替换字体。 (参考错误:找不到变量:Cufon)
【发布时间】:2012-04-27 15:21:46
【问题描述】:

我第一次尝试使用 Cufon 给我带来了一些问题,因为我似乎无法让它工作。 Coda 的 Javascript 日志给了我这个错误 (ReferenceError: Can't find variable: Cufon) 从几个教程中,我精确地遵循了它们,一遍又一遍地来回下载库,但没有任何效果。如果你们能看看并帮助我,将不胜感激。

这是我的代码;

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <title>Test</title>
    <!-- Styles go here -->
    <link rel="stylesheet" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" href="css/style.css" />
    <!-- End styles here -->

    <!-- Scripts go here -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script type="text/javascript" src="scripts/A.font.js"></script>
    <script type="text/javascript" src="scripts/cufon.js"></script>

    <script type="text/javascript">
        Cufon.replace("p");
    </script>
    <!-- Scripts end here -->
</head>

<body>

<p>Test</p>
Test

</body>
</html>

谢谢。

【问题讨论】:

    标签: javascript html cufon


    【解决方案1】:

    出现此错误是因为您在加载需要它的字体之后加载了Cufon,所以尝试更改顺序,首先加载cufon.js

    <script type="text/javascript" src="scripts/cufon.js"></script>
    

    然后加载A.font.js

    <script type="text/javascript" src="scripts/A.font.js"></script>
    

    【讨论】:

    • 感谢您指出我的错误。 :(真是个愚蠢的错误。谢谢。
    【解决方案2】:

    我知道这并不能直接回答您的问题,但请不要使用 Cufon。请改用 CSS 2.1 的 @font-face。它非常简单且 100% 可访问,而 Cufon 则不然。

    这里是您需要在 CSS 中使用 @font-face 的仅有 2 个链接:

    http://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntax http://www.fontsquirrel.com/fontface/generator

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-23
      • 1970-01-01
      • 1970-01-01
      • 2012-03-27
      • 2011-07-29
      • 2016-01-10
      • 1970-01-01
      • 2011-03-31
      相关资源
      最近更新 更多