【问题标题】:How to use google web fonts in IE, Firefox and Chrome如何在 IE、Firefox 和 Chrome 中使用谷歌网页字体
【发布时间】:2012-12-24 10:57:15
【问题描述】:

我正在尝试在我的网络应用程序中使用谷歌字体。我加载谷歌字体的电话是:

$.get("https://www.googleapis.com/webfonts/v1/webfonts?key=xxxxxxx", function (result) {                                             
        var data = {};
        console.log(result);
        console.log($.parseJSON(result));
        data.items = $.parseJSON(result).items;
});

上述调用在我的 3 个目标浏览器中给出以下结果:

火狐

console.log(result);               ========> JSON string
console.log($.parseJSON(result));  ========> Successfully parsed the json string
data.items = $.parseJSON(result).items; ===> contains all google fonts

IE (9)

$.get callback is not executing.

console.log(result);               ========> Object
console.log($.parseJSON(result));  ========> null

谁能告诉我在上述 3 个浏览器上使用谷歌字体的通用方法?

【问题讨论】:

    标签: javascript jquery google-font-api


    【解决方案1】:

    我发现了一个适用于 Firefox、IE 和 chrome 的通用调用:

    $.ajax({
        url: "https://www.googleapis.com/webfonts/v1/webfonts?key=xxxxx",
        type: 'GET',
        dataType: 'JSONP',
        success: function (data) {   
          // data.items contains all google font-families name
        }
    });
    

    愿这对其他人有所帮助!

    【讨论】:

      猜你喜欢
      • 2013-10-14
      • 2014-05-16
      • 1970-01-01
      • 2013-04-20
      • 2012-11-23
      • 2016-07-08
      • 2017-10-26
      • 2018-03-11
      • 2012-10-05
      相关资源
      最近更新 更多