Bootstrap - 没有JavaScript的Glyphicons?

时间:2014-03-09 17:06:47

标签: javascript twitter-bootstrap font-awesome glyphicons

我无法让Bootstrap中的Glyphicons在没有JavaScript的情况下工作。 启用JavaScript后,一切正常,但是当它被禁用时,它只显示随机符号。 (尝试在禁用JavaScript的情况下访问http://getbootstrap.com/components/

有没有办法可以使用这些图标而无需用户启用JavaScript?

我也考虑过使用Font Awesome,但http://fontawesome.io也有同样的问题。

编辑:好的,这很奇怪。它似乎在Opera中运行得非常好,而它在Firefox中并不适用。 我是否必须通过@ font-face或其他东西指定编码或包含字体?

另一个编辑:Firefox控制台显示以下内容:

downloadable font: download not allowed (font-family: "Glyphicons Halflings" style:normal weight:normal stretch:normal src index:1): content blocked
source: http://localhost/bs/fonts/glyphicons-halflings-regular.woff bootstrap.min.css

downloadable font: download not allowed (font-family: "Glyphicons Halflings" style:normal weight:normal stretch:normal src index:2): content blocked
source: http://localhost/bs/fonts/glyphicons-halflings-regular.ttf bootstrap.min.css

downloadable font: no supported format found (font-family: "Glyphicons Halflings" style:normal weight:normal stretch:normal src index:4)
source: (end of source list) bootstrap.min.css

2 个答案:

答案 0 :(得分:2)

Font Awesome的图标,不需要JavaScript,因为它说right there on the front page of their site。证明:http://jsbin.com/conerepu/1

Bootstrap使用的Glyphicons也没有;证明:http://jsbin.com/conerepu/2

仅仅因为他们的网站需要JavaScript,这并不意味着图标会这样做。

答案 1 :(得分:1)

好吧,看起来Firefox插件“NoScript”导致了这个问题。删除它并在FF本身中禁用JavaScript后,一切正常。

这不是我希望的答案,因为很多人都使用NoScript而且我不想让他们看到一个充满破碎图标的网站,所以我现在要把这些图标留下来。但至少我知道是什么原因导致了这个问题:/