简体   繁体   中英

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM