2014-10-07 51 views
1

假設注入了一板:
如何創建事件偵聽器,頁面腳本的自定義消息

//main.js 
    var ext = require("sdk/panel").Panel({ 
     width: 300, 
     height: 500, 
     contentScriptFile: [data.url("js/angular/angular.min.js"), 
          data.url("js/angular/angular-route.js"), 
          data.url("js/app.js"), 
          data.url("js/utilities.js"), 
          data.url("js/services.js"), 
          data.url("js/directives.js"), 
          data.url("js/controllers.js"), 
          data.url("js/popup.js")], 
     contentScriptWhen: "ready" 
    }); 

我可以附加一個偵聽DOM活動標籤的檢測某些事件:

if(window.customObj != undefined) 
{ 
    window.postMessage(window.customObj, window.location.href); 
} 

如何獲取我通過此自定義消息發送的對象popup.jsmain.js

回答

相關問題