Search code examples
javascriptfirefox-addonvimperator

How do I getElementByID in Vimperator?


I've searched quite a bit and can't find the answer to my question. How do I get getElementById to work in Vimperator?? Whenever I try, it tells me:

"document.getElementById(...) is null"

This is a sample of what I put in the command:

js document.getElementById("myDiv").style.color="blue";

Any help is very much appreciated! Thanks.


Solution

  • Because the js command scope is XUL Chrome scope. That is the global object window this a XUL Window. The html window object for seleted tab is window.content.window.

    So try to change your code to

    js window.content.window.document.getElementById("myDiv").style.color="blue";