Firefox extension, accessing the document
I am having trouble accessing the document in my firefox extension. I am trying to get *target*.addEventListener("DOMContentLoaded", Run.writeToFile(line.value), false);
to work, however I keep getting errors no matter what I try for my target. I have very little understanding of all of this and have pretty much tried everything I could find on the internet.
This seems to work for evaluating xpaths:
var doc = top.document.getElementById("content").selectedBrowser.contentDocument;
var item = doc.evaluate(
treeView.model[i].xpath,
doc,
null,
XPathResult.STRING_TYPE,
null);
doc.location.href
works for changing the URL.
So I tried using doc.addEventListener...
Here is开发者_StackOverflow社区 the error I get. [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: chrome://spextract/content/scripts/run.js :: anonymous :: line 35" data: no]
I also tried these -> firefox extension, jquery and accessing the document
All help is very much appreciated. And let me know if any more info would help.
Edit: Also, if anyone knows how to get it to work with window.onload, that would be helpful too.
I get my document using this:
var doc=window.content.document
if(doc != null) {
var data = doc.getElementById("detail")
....
}
Notice that this is only visible from the Extension scope.
精彩评论