1

嗨, 我正在使用crossrider創建IE擴展。在這個擴展中,我想通過點擊瀏覽器動作中的圖標來打開一個HTML頁面。當我點擊圖標的HTML頁面不會彈出。如何將html頁面設置爲在crossrider中的瀏覽器動作中彈出

請幫助

在background.js

appAPI.ready(function($) 
{ 
    appAPI.browserAction.setResourceIcon('icon128.png'); 
    appAPI.browserAction.setTitle('Tax2290 Extension'); 
    appAPI.browserAction.setPopup({resourcePath:'index.html'}); 
}); 

在extension.js

appAPI.ready(function($) { 
// Includes remote JS file into extension.js scope 
// Injects remote JS file into HTML page 
appAPI.dom.addRemoteJS('images/feed.js'); 
// Injects remote CSS file into HTML page 
appAPI.dom.addRemoteCSS('images/style.css'); 

}); 

回答

1

通常,appAPI.browserAction.setPopup作品以及在IE中,我不知道有任何問題。

在一般情況下,你必須確保資源引用(icon128.pnf,index.html的,...)被上傳到擴展的資源文件夾,該高度寬度強制性屬性在調用setPopup方法時指定。

此外,我不太清楚你的代碼在extension.js文件中的重要性,但是如果意圖將它們應用於彈出內容,那麼你必須在一個crossriderMain中定義它們您的index.html文件中功能,如下所示:

的index.html

<!DOCTYPE html> 
<html> 
<head> 
<!-- This meta tag is relevant only for IE --> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 

<script type="text/javascript"> 
/************************************************************************************ 
    This is your Popup Code. The crossriderMain() code block will be run 
    every time the popup is opened. 

    For more information, see: 
    http://docs.crossrider.com/#!/api/appAPI.browserAction-method-setPopup 
*************************************************************************************/ 

function crossriderMain($) { 
    // Place your code here (you can also define new functions above this scope) 
    // The $ object is the jQuery object 
    eval(appAPI.resources.get('images/feed.js')); 
    appAPI.resources.includeCSS('images/style.css'); 
} 
</script> 
</head> 
<body> 
Hello World 
</body> 
</html> 

如果您需要任何這方面的進一步的幫助,我將需要採取在細看碼。因此,請提供擴展名爲,我很樂意進行調查。

[免責聲明:我是一個Crossrider員工]

+1

謝謝你,這是一個有用的例子,從.setPopup文檔尚不清楚對我來說,crossriderMain是被包括在彈出HTML本身。它非常有意義,但是直到我看到上面的回覆時,錢纔沒落。 – NPC

相關問題