【发布时间】:2017-06-02 07:46:15
【问题描述】:
我正在为 Roblox 网页开发这个小型 chrome 扩展程序,但由于某种原因,它根本不想正常工作。
错误是
Uncaught TypeError: Cannot set property 'background' of undefined
at extension_update (themeManager.js:7)
at themeManager.js:14
这是代码:
var colorOnePath = document.getElementsByClassName("navbar-fixed-top rbx-header");
var colorTwoPath = [document.getElementsByTagName("body"), document.getElementsByClassName("content")];
var color = ["#008919", "#000000"];
function extension_update() {
colorOnePath.style.background = color[0];
colorTwoPath[0].style.background = color[1];
colorTwoPath[1].style.background = color[1];
setTimeout(1000, extension_update)
};
extension_update()
我不知道为什么代码是这样设置的,但是无论如何,有什么地方有问题吗?我找不到修复的地方。谢谢!
【问题讨论】:
-
注意 -
document.getElementsByTagName("body")[0]===document.body
标签: javascript google-chrome google-chrome-extension roblox