如何在最新的Firefox中单击输入类型=“提交”?

时间:2022-09-25 15:30:17

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:

我为Facebook制作了非常受欢迎的UserJS,但是自从FF 3.6.13版本起它不起作用(对于那个版本)。我只是不知道如何点击这些元素:

<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();

我的脚本做的是用Xpath搜索这些元素,然后用简单的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 * and which help me often, but this time they can't.

它适用于Opera,Chrome和FF <3.6.13,但在最新版本中没有任何反应。我也尝试了fireEvent和eventFire函数,我在这里找到了*,这对我经常有帮助,但这次他们不能。

Probably using JQuery's click() function would help ,but I cannot use jquery in my userjs.

可能使用JQuery的click()函数会有所帮助,但我不能在我的userjs中使用jquery。

I tried also acceptbutton.form.submit(); but it redirects me to wrong page.

我也尝试过acceptbutton.form.submit();但它会将我重定向到错误的页面。

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!

谢谢你的帮助!

3 个解决方案

#1


1  

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?

您可以使用最新Firefox中提交按钮的click()方法。你还有别的错。您是否在表单上有一个阻止点击工作的onsubmit事件,或者您是否有错误的按钮?

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

我通过粘贴javascript提交了这个:document.getElementById('submit-button')。click();空隙(0);在Firefox 3.6.13的我的位置栏中。这个想法归功于此:使用NAME进行JavaScript自动发布

#2


0  

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

嗯,不要做一个简单的document.whatever_formname.submit();这个伎俩?

#3


0  

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?

如果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();

#1


1  

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?

您可以使用最新Firefox中提交按钮的click()方法。你还有别的错。您是否在表单上有一个阻止点击工作的onsubmit事件,或者您是否有错误的按钮?

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

我通过粘贴javascript提交了这个:document.getElementById('submit-button')。click();空隙(0);在Firefox 3.6.13的我的位置栏中。这个想法归功于此:使用NAME进行JavaScript自动发布

#2


0  

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

嗯,不要做一个简单的document.whatever_formname.submit();这个伎俩?

#3


0  

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?

如果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();