【问题标题】:Google Fonts giving: No 'Access-Control-Allow-Origin' header is present on the requested resource谷歌字体给出:请求的资源上没有“Access-Control-Allow-Origin”标头
【发布时间】:2014-10-30 21:55:33
【问题描述】:

我正在尝试使用谷歌字体“Oswald”。当我将它嵌入到我的页面中时recommended way:

<link href='http://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css'>

Chrome 抛出以下错误:

XMLHttpRequest cannot load http://fonts.googleapis.com/css?family=Oswald:400,300,700. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://<<redacted>>' is therefore not allowed access. 

这只是谷歌的错误还是我做错了什么?

【问题讨论】:

  • 顺便说一句,您不应该使用 ' 来分隔 HTML 标记中的参数值。这不标准,而且完全是错误的。
  • @Qualcuno 嗯,谢谢,但这是直接从 Google 字体页面复制的。 google.com/fonts#UsePlace:use/Collection:Oswald

标签: fonts google-font-api


【解决方案1】:

原来是和prefixfree冲突

解决方案是在链接标签中添加“data-noprefix”,如下所示:

<link href='http://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css' data-noprefix>

【讨论】:

  • 谢谢,但我过去在某些浏览器中遇到过 // 问题。如果该网站没有 SSL 证书,我不明白为什么这很重要。
  • 不,它没有,但这意味着您无法安装 SSL 而不引起通知
  • 我添加了“data-noprefix”,但仍然出现错误。
猜你喜欢
  • 2014-11-24
  • 2017-02-07
  • 2023-03-16
  • 2014-07-30
  • 2016-01-14
  • 2023-03-15
  • 2018-12-02
  • 2015-10-30
  • 2019-10-07
相关资源
最近更新 更多