2015-03-02 130 views
0

是否可以使用Firefox擴展創建OS浮動窗口?以便在瀏覽器失去焦點時顯示窗口。谷歌搜索沒有帶來太多。只需要一些教程/寫在這。創建os浮動窗口Firefox擴展

目標操作系統 - Mac OS X,如果它很重要。

我很抱歉,如果你發現這個問題很愚蠢。起初我想知道這樣做是否可行和可行。 任何想法表示讚賞。

回答

0

從螢火蟲工作組的像素完美延伸正是這樣做的 - 請參見本文件爲全面實施:

https://github.com/firebug/pixel-perfect/blob/master/lib/pixel-perfect-popup.js

的核心代碼創建彈出在一種稱爲「 createPanel'on line 149

createPanel: function() { 
    let browser = getMostRecentBrowserWindow(); 
    let doc = browser.document; 

    this.panel = doc.createElementNS(XUL_NS, "panel"); 
    this.panel.setAttribute("id", "pixel-perfect-panel"); 
    this.panel.setAttribute("noautohide", "true"); 
    this.panel.setAttribute("titlebar", "normal"); 
    this.panel.setAttribute("noautofocus", "true"); 
    this.panel.setAttribute("label", Locale.$STR("pixelPerfect.title")); 
    this.panel.setAttribute("close", "true"); 
    this.panel.style.border = "0"; 

    this.panelFrame = doc.createElementNS(XUL_NS, "iframe"); 
    this.panelFrame.setAttribute("type", "content"); 
    this.panelFrame.setAttribute("border", "0"); 
    this.panelFrame.setAttribute("flex", "1"); 

    // xxxHonza: unregister listeners? 
    DomEvents.on(this.panel, "popuphidden", this.onPopupHidden); 
    DomEvents.on(this.panel, "popupshown", this.onPopupShown); 

    this.panelFrame.setAttribute("src", self.data.url("./popup.html")); 
    this.panel.appendChild(this.panelFrame); 

    let container = doc.getElementById("mainPopupSet"); 
    container.appendChild(this.panel); 

    // Load content script and handle messages sent from it. 
    let { messageManager } = this.panelFrame.frameLoader; 
    if (messageManager) { 
    let url = self.data.url("popup-frame-script.js"); 
    messageManager.loadFrameScript(url, false); 
    messageManager.addMessageListener("message", this.onMessage); 
    messageManager.addMessageListener("sdk/event/ready", this.onPanelReady); 
    } 

    return this.panel; 
}, 
+0

感謝提示,但面板在瀏覽器丟失時會失去焦點。然後選擇面板窗口將整個瀏覽器窗口返回。我的問題是 - 是否有可能在其他操作系統窗口的頂部顯示該面板?某種浮動或粘滯的窗口。 – iurii 2015-03-03 08:21:33

相關問題