Created
March 24, 2014 18:56
-
-
Save ZER0/9746736 to your computer and use it in GitHub Desktop.
Open a HTML Document dialog in Add-on SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Open a plain dialog */ | |
const { getActiveTab, setTabURL } = require('sdk/tabs/utils'); | |
const { open } = require('sdk/window/helpers'); | |
const { data } = require('sdk/self'); | |
const url = data.url('foo.html'); | |
open("", { | |
features: { | |
toolbar: false, | |
resizable: true, | |
scrollbars: true, | |
width: 200, | |
height: 400 | |
} | |
}).then(window => setTabURL(getActiveTab(window), url)); | |
/* If a content script needs to be attached to the dialog */ | |
const { getActiveTab, setTabURL, getTabId } = require('sdk/tabs/utils'); | |
const { open } = require('sdk/window/helpers'); | |
const { data } = require('sdk/self'); | |
const url = data.url('foo.html'); | |
const tabs = require('sdk/tabs'); | |
open("", { | |
features: { | |
toolbar: false, | |
resizable: true, | |
scrollbars: true, | |
width: 200, | |
height: 400 | |
} | |
}).then(window => { | |
let xulTab = getActiveTab(window); | |
let id = getTabId(xulTab); | |
tabs.on('ready', function ready(tab) { | |
if (tab.id === id) { | |
tabs.removeListener('ready', ready); | |
tab.attach({ | |
contentScript: 'alert("hello")' | |
}); | |
} | |
}); | |
setTabURL(xulTab, url); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment