2009-12-18 77 views
1

我正在嘗試製作類似於下圖的內容。使用彈出式欄的Chrome擴展程序

http://img696.imageshack.us/img696/8844/testi.jpg

不幸的是,我似乎無法得到它的擴展範圍內工作。我收到一個錯誤,指出「加載文檔時出錯」。上面的屏幕截圖是使用iBox JavaScript本地製作的HTML完成的。有沒有其他的JavaScript庫允許我加載我的彈出式HTML,就像它在圖標欄中的圖標一樣?

這是怎樣的代碼在本地實現打開彈出:

document.addEventListener('keydown', function(e){ 
     if (e.keyCode == 81 && e.altKey && !e.shiftKey && e.ctrlKey) { 
      iBox.showURL('search.html'); 
      } 
     }, false); 

這是iBox的庫函數:

showURL: function(url, title, params) { 
     showInit(title, params, function() { 
      for (var i=0; i<_pub.plugins.list.length; i++) { 
       var plugin = _pub.plugins.list[i]; 
       if (plugin.match(url)) { 
        active.plugin = plugin; 
        plugin.render(url, active.params); 
        break; 
       }}});} 

這是XMLHTTP請求:

if (window.XMLHttpRequest) { // Mozilla, Safari,... 
      http = new XMLHttpRequest(); 
      if (http.overrideMimeType) { 
       // set type accordingly to anticipated content type 
       http.overrideMimeType('text/html'); 
      } 
     } 
+0

後的代碼片段:我也許能提供幫助。 – jldupont 2009-12-18 15:17:09

+0

已更新,請告訴我,您是否在尋找 – Guibone 2009-12-18 15:32:05

+0

以及「search.html」文檔位於何處? – jldupont 2009-12-18 15:34:40

回答

0

一種可能性是manifest.json中的權限未正確設置。如果擴展依賴於創建XMLHttpRequest,則需要查看此doc

當然,如果所有的iBox「應用程序」的相關文件都位於你的擴展文件夾,它應該沒問題。

+0

是的。我還在manifest.json中用「js」加載它:[「contentScript.js」,「ibox.js」] – Guibone 2009-12-18 16:05:45

+0

你是什麼意思?是相應設置的'permissions'列表嗎?請澄清。 – jldupont 2009-12-18 16:12:45

+0

對不起。我的意思是說,「content_scripts」具有上述行。如果iBox將XMLHttpRequests設置爲外部來源,則功能上的擴展功能 – Guibone 2009-12-18 16:17:31