Reputation: 799
When I run my code, it comes up with "about blank" instead of my extension options. I would like it to open the options in front of the extensions. Here is some of my extension code-
popup.js:
document.getElementById('div_options').onclick = openOps;
function openOps() {
window.open("chrome://extensions/?options=pgapbgeppkbeghldobmjehpbdleapdip");
closeAndReloadPopup();
};
popup.html:
<li>
<a href="#"><div id="div_options">Options</div></a>
</li>
manifest.json:
{
"background": {
"page": "background.html"
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"page_action": {
"default_icon": {
"19": "images/icon19.png",
"38": "images/icon38.png"
},
"default_title": "Scratch theme loader",
"default_popup": "popup.html"
},
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"web_accessible_resources": ["src/options/options.html"],
"permissions": [
"tabs",
"storage",
"declarativeContent",
"https://scratch.mit.edu/*",
"https://pastebin.com/raw/*"
]
}
options.html:
<html>
<stuff>
</html>
Upvotes: 6
Views: 5679
Reputation: 20458
Use the recommended way: chrome.runtime.openOptionsPage(callback)
Open your Extension's options page, if possible. The precise behavior may depend on your manifest's options_ui or options_page key, or what Chrome happens to support at the time. For example, the page may be opened in a new tab, within chrome://extensions, within an App, or it may just focus an open options page. It will never cause the caller page to reload. If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set lastError.
https://developer.chrome.com/extensions/runtime#method-openOptionsPage
Alternatively, chrome.tabs.create({ url: "chrome://extensions/?options=" + chrome.runtime.id }, callback)
or chrome.tabs.create({ url: "options.html" }, callback)
Upvotes: 12