如何点击输入type=“提交”在最新的火狐浏览器中?

发布于 2024-10-09 19:38:27 字数 1208 浏览 1 评论 0原文

我为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟酉 2024-10-16 19:38:27

可以使用最新版 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

冷默言语 2024-10-16 19:38:27

嗯,不会做一个简单的 document.whatever_formname.submit();做这件事吗?

Hmm, wont do a simple document.whatever_formname.submit(); do the trick?

三五鸿雁 2024-10-16 19:38:27

如果由于未发送 value="Accept" 部分而导致 acceptbutton.form.submit(); 不起作用,为什么不添加一个隐藏输入,以便将其?

var hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = acceptbutton.name;
hiddenInput.value = acceptbutton.value;
acceptbutton.form.appendChild(hiddenInput);
acceptbutton.form.submit();

If acceptbutton.form.submit(); doesn't work because the value="Accept" part is not sent, why not add a hidden input so that it will be?

var hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = acceptbutton.name;
hiddenInput.value = acceptbutton.value;
acceptbutton.form.appendChild(hiddenInput);
acceptbutton.form.submit();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文