Не работает button и JS в расширении
Разрабатываю Firefox расширение, при разработке столкнулся с двумя проблемами - button не работает и JS не срабатывает. Коды ниже
<html>
<head>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<input type="text" placeholder="Image URL" id="urlinput"/>
<br>
<p style="font-size:32px;text-align:center;" id="status">Chat field: </p>
<select id="chatselect">
<option>Darker</option>
<option>Lighter</option>
<option>Black</option>
<option>Don't fill</option>
</select>
<br>
<button id="submit" type="submit" value=".">Submit</button>
<script src="index.js"></script>
</body>
</html>
document.body.getElementById("status").innerText = "3Done!";
document.addEventListener("click", (e) => {
document.body.getElementById("status").innerText = "1Done!";
if (e.target.id == "submit") {
let url = document.body.getElementById("urlinput").value
let mode = document.body.getElementById("chatselect").options[document.body.getElementById("chatselect").selectedIndex]; //fun
document.body.getElementById("status").innerText = "2Done!";
browser.tabs.executeScript(null, {
file: "change.js"
});
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
gettingActiveTab.then((tabs) => {
browser.tabs.sendMessage(tabs[0].id, {url: url, mode: mode});
});
}
});
Буду благодарен любой помощи
Ответы (1 шт):
Автор решения: kingley
→ Ссылка
Проблема была в ошибке в коде (вместо document.body.getElement надо было писать document.getElement)