开发者

form.submit() causes uncaught exception in greasemonkey

I'm using a greasemonkey script to load a page with ajax and automatically fill in the form fields inside the page and submit the form. The problem is that when the form.submit() stateme开发者_JAVA技巧nt is executed I get an uncaught exception error:

"uncaught exception: [Exception... "Component is not available"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"
         //location: "JS frame ::
file:///home/user/.mozilla/firefox/kwrkmbls.default/extensions/%7Be4a8a97b-f2ed-450b-b12d-ee082ba24781%7D/components/greasemonkey.js
:: anonymous :: line 375"  data: no]" 

Strangely, if I don't use ajax to load the page, but load it manually instead, the same code works; All fields are filled in and the form is submitted.

Any idea what's at fault;


you can't just to request the content and try to execute it. you need to append it to the current page. something like:

document.body.appendChild(iframe);
iframe.addEventListener("load", function(e)
{
    e.target.contentDocument.forms.namedItem("namedForm").submit();
}, false);

havent tested it but you got the idea

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜