2013-01-24 2 views
0

비슷한 문제가 발생하지만 이유는 확실하지 않습니다.Webfont Loader & Google JSAPI 함께로드 할 수 없습니까?

fonts.com에서 webfontloader로 글꼴을로드하려고 했으므로로드 된 후에 함수를 호출 할 수 있습니다.

<script src="https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script> 
<script> 
    WebFont.load({ 
     monotype: { 
     projectId: 'xxxxxxxxxxxxxxxxxxxx' 
     }, 
     active: function() { 
     mainNav(); 
     } 
    }); 

그러나 때 나는 JSAPI으로 포함 이제까지

<script src="https://www.google.com/jsapi"></script> 

I 얻을 콘솔에서 다음 문제 : catch되지 않은 형식 오류 : 널 (null)

방법 'hasAttribute'을 호출 할 수 없습니다

하지만 별도로로드하면 괜찮습니다 ...

아이디어가 있으십니까?

답변

2

웹 글꼴 API를로드하려면 다음 URL을 사용하십시오 : 자세한 내용은

<script src="//ajax.googleapis.com/ajax/libs/webfont/1.1.2/webfont.js"></script> 

확인 다음 게시물 : https://groups.google.com/forum/#!msg/google-ajax-search-api/dWVzQF_YWCM/Y3-R738wh78J

We no longer support partial version aliases for new versions of libraries. Any partial version aliases already in place will continue to be supported and updated. The reason is that URLs like https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js which is saying "give me the most recent version of jquery 1.x.x) have very short cache lifetimes since the most recent version can change at any time. This is bad for performance. This is also bad for your web site, in the event that a library makes breaking changes in its APIs between versions that cause your page to suddenly render differently. Libraries do not usually make such changes intentionally but pages sometimes depend on behavior of an unspecified corner case of an API that may be changed intentionally or inadvertently as the library is updated.

So we strongly recommend that you specify the complete version string when referencing libraries hosted on the Google AJAX APIs. You can always find the most recent version at https://developers.google.com/speed/libraries/devguide . In this case, the most recent 1.9.x version is currently 1.9.1 so we suggest using the URL https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js to get a stable version and better caching.

은 (또한, 귀하의 예는 위의 마감을하지 않습니다 </script> 태그입니다. 자신의 코드에 없는지 확인하고 싶습니다.)