Answer the question
In order to leave comments, you need to log in
Why does it throw Uncaught TypeError: Cannot read properties of undefined (reading 'split')?
I made an extension, wrote the code:
let changeColor = document.getElementById('buttonBg');
if (changeColor != null) {
changeColor.onclick = function(el) { //ругается на эту строку.
let colorBg = '#333';
let colorText = '#fff'
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{code: 'document.body.style.backgroundColor = "' + colorBg + '";document.body.style.color = "' + colorText + '"'}
);
})
}
}
Answer the question
In order to leave comments, you need to log in
onload
- can. Just not .
True, this is not necessary, for it is indicated when to run it in the parameter .
Similarly, not , but . In general, forget about when you climb on other people's pages. There can be only one such handler, while there can be as many as you like.
Well, I don’t see anywhere in your code that the error is complaining about, so somewhere you are lying. onload
addEventListener('load', ...)
split
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question