working on my first Chrome Extension and running into a problem. I want to be able to have on the options.html page a checkbox for deciding if it should open in a tab or windows. I have the following code which isn't working:
options.html
<div class="checkbox">
<label>
<input type="checkbox" id="useTab"> Open as Tab?
</label>
</div>
background.js
chrome.browserAction.onClicked.addListener(
function(tab) {
if(document.getElementById('useTab').checked) {
chrome.tabs.create({
url: chrome.runtime.getURL("<website>"),
//type: "popup"
}, function(win) {
});
}
else {
chrome.windows.create({
url: chrome.runtime.getURL("<website>"),
//type:popup"
}, function(win) {
});
}
}
);
The idea of the code is such that when the extension icon in the browser is selected, the function is run from background.js, and if the option checkbox is checked it opens as a tab, and if it isn't, it is opened as a window.