尝试使用GreaseMonkey提交表单,但该页面停止工作 [英] Trying to submit a form with GreaseMonkey, but the page stops working
问题描述
我需要在特定页面上提交表单,并且在提交表单之前需要单击一个单选按钮。
I need to submit a form on a specific page, and it needs to click a radio button before it submits the form.
我让GreaseMonkey提交表单,页面只是返回一个白页。如果我点击手动提交,它会显示'请稍等..',然后进入另一个页面。
I got everything working, however when I let GreaseMonkey submit the form the page just returns a white page. As where if I would click Submit manually, it says 'Wait a second please..' and then goes on to another page.
如果需要,我可以为您提供网址我正在谈论的形式。
If neccessary I can give you the URL of the form I am talking about.
这是我使用的脚本:
$(document).ready(function() {
$("input[pmmethod=paypal]").click();
$(".submit-button").click();
});
推荐答案
听起来像事件处理程序附加到按钮,您可以尝试使用原生JavaScript而不是jQuery方法来模拟鼠标点击;
Sounds like a event handler is attached to the button, you could try to simulate a mouse click on it using native JavaScript instead of the jQuery method;
function simulateClick(node) {
var ev = document.createEvent("MouseEvents");
ev.initMouseEvent("click", true, false, self, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
return node.dispatchEvent(ev);
}
$(document).ready(function() {
$("input[pmmethod=paypal]").click();
simulateClick( $(".submit-button")[0] );
});
这篇关于尝试使用GreaseMonkey提交表单,但该页面停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!