2010-11-07 9 views
1

當我從一個函數加載庫時,它不會加載甚至崩潰頁面!
這是怎麼回事?Google圖書館API - google.load不會從事件加載?

HTML頭:

<script type="text/javascript" src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY"></script> 
<script type="text/javascript"> 
    // --- LOADING LIKE THIS WORKS FINE --- 
    // jQuery is completely loaded 
    function jqueryLoaded() { 
     $("body").css("background-color","orange"); 
    } 
    google.load("jquery", "1.4.3"); 
    google.setOnLoadCallback(jqueryLoaded);  

    // --- LOADING FROM AN EVENT DOES NOT WORK?? --- 
    // jQuery UI is completely loaded 
    function jqueryUILoaded() { 
     $("body").css("background-color","green"); 
    } 
    function loadJqueryUI() { 
     alert("load jQuery UI now.."); 
     google.load("jqueryui", "1.8.6"); 
     google.setOnLoadCallback(jqueryUILoaded); 
    } 

    // with a setTimeout it doesn't work either.. 
    // setTimeout("loadJqueryUI()", 2000); 
</script> 

HTML體:

<input type="button" value="load jQuery UI" onclick="loadJqueryUI()"/> 

回答

0

你有沒有考慮過用,ERM更換INSERT-YOUR-KEY,你的鑰匙?

+0

是的,我做到了,順便說一句本地似乎有必要不。 – FFish 2010-11-07 11:42:04