我搜索了很多,但找不到我的问题的答案。如何让 getElementById
在 Vimperator 中工作?每当我尝试时,它都会告诉我:
"document.getElementById(...) is null"
这是我在命令中输入的示例:
js document.getElementById("myDiv").style.color="blue";
非常感谢任何帮助!谢谢。
最佳答案
因为 js
命令作用域是 XUL Chrome 作用域。这是全局对象 window
这是一个 XUL 窗口。所选选项卡的 html 窗口对象是 window.content.window
。
所以试着把你的代码改成
js window.content.window.document.getElementById("myDiv").style.color="blue";
关于javascript - 我如何在 Vimperator 中获取 ElementByID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15995201/