admin管理员组文章数量:1415137
I'm writing a Google Chrome Extension for my first time and I am trying to use alert() to create a dialog box however when it runs I encounter a problem. The title isn't the name of the extension - instead it is the extension ID ("chrome-extension://..... says").
I want the title to say the name of the extension, not the ID. Here is my code:
manifest.json
{
//Extension Details
"manifest_version": 2,
"name": "Test Extension",
"description": "Test Extension",
"version": "1.0",
"icons" :
{
"16": "PI-Logo.png",
"32": "PI-Logo.png",
"64": "PI-Logo.png"
},
//Main HTML Action
"browser_action":
{
"default_icon": "PI-Logo.png",
"default_popup": "popup.html"
},
//Permissions
"permissions":
[
"activeTab",
"/",
"<all_urls>"
],
"chrome_url_overrides":
{
"newtab" : "newtab.html"
},
//Scripts
"content_scripts":
[
{
"matches": ["/*", "/*"],
"js": ["myScript.js"]
}
],
"background":
{
"scripts": ["background.js"]
}
}
myScript.js
chrome.runtime.sendMessage("Hello World!");
background.js
chrome.runtime.onMessage.addListener(function(response, sender, sendResponse) {
alert(response);
});
I don't know that much about javascript or HTML - I'm an amateur at this. Any help would be appreciated as to how I could fix this. Thank you!
I'm writing a Google Chrome Extension for my first time and I am trying to use alert() to create a dialog box however when it runs I encounter a problem. The title isn't the name of the extension - instead it is the extension ID ("chrome-extension://..... says").
I want the title to say the name of the extension, not the ID. Here is my code:
manifest.json
{
//Extension Details
"manifest_version": 2,
"name": "Test Extension",
"description": "Test Extension",
"version": "1.0",
"icons" :
{
"16": "PI-Logo.png",
"32": "PI-Logo.png",
"64": "PI-Logo.png"
},
//Main HTML Action
"browser_action":
{
"default_icon": "PI-Logo.png",
"default_popup": "popup.html"
},
//Permissions
"permissions":
[
"activeTab",
"https://ajax.googleapis./",
"<all_urls>"
],
"chrome_url_overrides":
{
"newtab" : "newtab.html"
},
//Scripts
"content_scripts":
[
{
"matches": ["http://www.google./*", "https://www.google./*"],
"js": ["myScript.js"]
}
],
"background":
{
"scripts": ["background.js"]
}
}
myScript.js
chrome.runtime.sendMessage("Hello World!");
background.js
chrome.runtime.onMessage.addListener(function(response, sender, sendResponse) {
alert(response);
});
I don't know that much about javascript or HTML - I'm an amateur at this. Any help would be appreciated as to how I could fix this. Thank you!
Share Improve this question edited Mar 17, 2016 at 13:40 Xan 77.7k18 gold badges197 silver badges217 bronze badges asked Mar 17, 2016 at 6:10 Penguix DarkePenguix Darke 111 silver badge2 bronze badges 2- For the record - please don't use snippets in future unless it's a short demo code that can actually be run. Just use code blocks - indent your code by 4 spaces. – Xan Commented Mar 17, 2016 at 13:40
- Oh okay sorry this is my first time posting. Thanks for the info, I will do that in the future! – Penguix Darke Commented Mar 17, 2016 at 16:56
1 Answer
Reset to default 3No you can't. The JavaScript alert box title can't be changed for security reason (fishing and stuff like that).
There is plenty of library for modal pop-up in JavaScript, but in your case, it can be difficult to because you have to inject it in all pages...
An other way to do almost what you want is to use the desktop notification API. It open little pop-up on the bottom right corner of the screen and you can customize the title. More information here.
本文标签: javascriptHow To Change Title For Alert Dialog Box For Chrome ExtensionStack Overflow
版权声明:本文标题:javascript - How To Change Title For Alert Dialog Box For Chrome Extension - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745226245a2648620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论