如何点击输入type=“提交”在最新的火狐浏览器中?
我为 Facebook 制作了非常流行的 UserJS,但从 FF 3.6.13 版本开始,它不起作用(对于该版本)。我只是不知道如何单击这些元素:
<input value="Accept" type="submit" name="something... asdf" />
?用鼠标单击此类按钮会重定向到另一个页面。
我的脚本所做的是使用 Xpath 搜索此类元素,然后使用简单的 acceptbutton.click();
单击它们。
它在 Opera、Chrome 和 FF <3.6.13 上运行良好,但在最新版本中没有任何效果发生。我还尝试了 fireEvent 和 eventFire 函数,我在 stackoverflow 上找到了它们,它们经常对我有帮助,但这次它们不能。
可能使用 JQuery 的 click()
函数会有所帮助,但我无法在我的 userjs 中使用 jquery。
我也尝试了 acceptbutton.form.submit();
但它会将我重定向到错误的页面。
编辑:
好的,我正在添加代码片段
var acceptbuttons = xpath(document,'//label[@class="uiButton uiButtonConfirm"]/input');
for (var i = 0; i < acceptbuttons.snapshotLength; i++) {
//will search for particular accept button
var acceptbutton = acceptbuttons.snapshotItem(i);
var acceptbuttonName = acceptbutton.getAttribute("name");
if(acceptbuttonName.indexOf(urlPart)!=-1)
{
// it founds button but function below do nothing in FF
acceptbutton.click();return;
}
}
感谢您的帮助!
I made quite popular UserJS for Facebook, but since FF 3.6.13 version it doesn't work (for that version). I just have no idea how can I click such elements:
<input value="Accept" type="submit" name="something... asdf" />
? Clicking such buttons with mouse redirects to another page.
What my script does is searching for such elements with Xpath and then clicking them with simple acceptbutton.click();
It works great on Opera, Chrome and FF <3.6.13 , but in newest version nothing happens. I tried also both fireEvent and eventFire functions which I've found here on stackoverflow and which help me often, but this time they can't.
Probably using JQuery's click()
function would help ,but I cannot use jquery in my userjs.
I tried also acceptbutton.form.submit();
but it redirects me to wrong page.
Edit :
Ok i am adding code fragment
var acceptbuttons = xpath(document,'//label[@class="uiButton uiButtonConfirm"]/input');
for (var i = 0; i < acceptbuttons.snapshotLength; i++) {
//will search for particular accept button
var acceptbutton = acceptbuttons.snapshotItem(i);
var acceptbuttonName = acceptbutton.getAttribute("name");
if(acceptbuttonName.indexOf(urlPart)!=-1)
{
// it founds button but function below do nothing in FF
acceptbutton.click();return;
}
}
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用最新版 Firefox 中提交按钮的
click()
方法。你还有别的问题。表单上是否存在阻止单击工作的 onsubmit 事件,或者按钮是否错误?我通过粘贴 javascript 提交了此内容: document.getElementById('submit-button').click(); void(0); 在 Firefox 3.6.13 的地址栏中。这个想法的功劳如下:JavaScript auto-POST with NAME
You can use the
click()
method of the submit button in the latest Firefox. You have something else wrong. Do you have an onsubmit event on the form that is preventing the click from working, or do you have the wrong button?I submitted this by pasting
javascript: document.getElementById('submit-button').click(); void(0);
in my location bar in Firefox 3.6.13. Credit for that idea goes here: JavaScript auto-POST with NAME嗯,不会做一个简单的 document.whatever_formname.submit();做这件事吗?
Hmm, wont do a simple document.whatever_formname.submit(); do the trick?
如果由于未发送
value="Accept"
部分而导致acceptbutton.form.submit();
不起作用,为什么不添加一个隐藏输入,以便将其?If
acceptbutton.form.submit();
doesn't work because thevalue="Accept"
part is not sent, why not add a hidden input so that it will be?