Firefox addon 输入类型的问题=";文件";在Mozilla web扩展中
我正在将扩展从Chrome移植到Firefox 有一个html与Firefox addon 输入类型的问题=";文件";在Mozilla web扩展中,firefox-addon,Firefox Addon,我正在将扩展从Chrome移植到Firefox 有一个html与 <input type="file" id="protocol-file"/> 但它不起作用-我看不到选择文件后的警报 看来扩展完成了在Firefox中选择文件的工作。在Chrome中,一切正常 index.html <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="tex
<input type="file" id="protocol-file"/>
但它不起作用-我看不到选择文件后的警报
看来扩展完成了在Firefox中选择文件的工作。在Chrome中,一切正常
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<script src="main.js"></script>
<body>
<div id="container">
<div class="file-input-block">
<span class="file-label">Файл:</span>
<input type="file" id="protocol-file"/>
</div>
</div>
</body>
</html>
manifest.json
{
"name": "Example",
"version": "0.1",
"description": "Mozilla ext example",
"manifest_version": 2,
"permissions": [
"activeTab",
"tabs",
"notifications",
"http://*/",
"https://*/"
],
"browser_action": {
"default_title": "Example file select",
"default_popup": "index.html"
},
"browser_specific_settings": {
"gecko": {
"id": "my@examle.com",
"strict_min_version": "49.0"
}
}
}
请选择要讨论的问题:包括重复问题的问题。对于Chrome扩展或Firefox WebExtensions,您几乎总是需要包含manifest.json和一些背景、内容和/或弹出脚本/HTML,通常还有网页HTML/scripts。寻求调试帮助的问题(“为什么我的代码没有按我想要的方式工作?”)必须包括:(1)所需的行为,(2)特定的问题或错误,(3)在问题本身中重现它所需的最短代码。另请看:,和@Makyen,你有没有发现任何@Natalyamayeva??我也面临同样的问题,在chrome上,它工作得很好,它阻止了扩展关闭,但是firefox将焦点移到了选择文件窗口,从而关闭了扩展。如果扩展控制台中的“阻止扩展关闭”选项处于活动状态,则该选项不会关闭,因此我将其缩小到目前为止的焦点问题。请回答主题中的问题:包括重复该问题的问题。对于Chrome扩展或Firefox WebExtensions,您几乎总是需要包含manifest.json和一些背景、内容和/或弹出脚本/HTML,通常还有网页HTML/scripts。寻求调试帮助的问题(“为什么我的代码没有按我想要的方式工作?”)必须包括:(1)所需的行为,(2)特定的问题或错误,(3)在问题本身中重现它所需的最短代码。另请看:,和@Makyen,你有没有发现任何@Natalyamayeva??我也面临同样的问题,在chrome上,它工作得很好,它阻止了扩展关闭,但是firefox将焦点移到了选择文件窗口,从而关闭了扩展。如果扩展控制台中的“阻止扩展关闭”选项处于活动状态,则它不会关闭,因此我将其缩小到目前为止的焦点问题。
document.addEventListener('DOMContentLoaded', function(){
document.getElementById('protocol-file').onchange = function() {
alert('protocol-file changed');
};
});
{
"name": "Example",
"version": "0.1",
"description": "Mozilla ext example",
"manifest_version": 2,
"permissions": [
"activeTab",
"tabs",
"notifications",
"http://*/",
"https://*/"
],
"browser_action": {
"default_title": "Example file select",
"default_popup": "index.html"
},
"browser_specific_settings": {
"gecko": {
"id": "my@examle.com",
"strict_min_version": "49.0"
}
}
}