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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745226246a4617474.html
评论列表(0条)