Question

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.

Was it helpful?

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";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top