I would like to play a simple "alarm" in chrome extension but i have and error in console: " GET chrome-extension://invalid/ net::ERR_FAILED
chrome-extension://invalid/:1
" My simple code is:
var asdasd = '<span id="audio"></span>';
$('body').append(asdasd);
var srcaudio = chrome.extension.getURL('alert2.mp3');
$('#audio').html('<audio autoplay><source src="'+srcaudio+'"></audio>');
And my manifest is:
{
"manifest_version": 2,
"name": "test",
"description": "test",
"version": "1.0",
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["jquery.js","myscript.js"]
}
]
}
So i tried to do this in my own extension.
As wOxxOm said, you probably need web_asseible_resources
. For me the css/js/fonts are in the assets package. I dunno where you placed it.
"web_accessible_resources": [
"assets/css/*",
"assets/js/*",
"assets/fonts/*"
]
Secondly, extension.getUrl()
is deprecated, so use runtime.getUrl()
instead, as for the url try to use "./alert2.mp3"
or "~/alert2.mp3"
if the direct path isn't working
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.