Thanks for the reply. This is a very nifty function I'll have to play
around with and see if I can get it to work. In my case there seems to
be a of elements that could be the one needing to be clicked. I was
looking around at the initMouseEvent parameters and it seems you can
offer a clientX, clientY, screenX, screenY to be clicked. Do you know
if I can have the mouse click somewhere on the screen without passing
an element?

On Dec 30, 10:06 pm, cc <carlcl...@lavabit.com> wrote:
> Personally, I use a utility function I borrowed from a popular GM script
> on userscripts.org:
>
> /* ===== Click on an element (borrowed from Facebook Fixer, 
> @namespacehttp://userscripts.org/people/14536) ===== */
> function click(elm) {
>      var evt = document.createEvent('MouseEvents');
>      evt.initMouseEvent('click', true, true, window, 0, 1, 1, 1, 1, false, 
> false, false, false, 0, null);
>      elm.dispatchEvent(evt);
>
> }
>
> It works very nicely for everything I've tried it on so far. The basic
> mechanism is to simulate a mouse click by dispatching a click event to
> the element in question, which seems to do just about everything you
> could wish (it does in fact trigger Firefox's built-in clicking
> mechanisms, too).
>
> HTH.
>
> On 2009-12-30 15:47, Kip wrote:
>
>
>
> > Hello everyone,
> >    I just started using grease monkeys and am attempting to code a
> > greasemonkey script. This script is supposed to click this button
> > automatically when it goes to this website.
>
> > ===website source code===
> >            <form method="post" name="form1" id="s2t">
>
> >    // Omitted info not related to button
>
> >                            <p style="display:none;"><input type="submit"  
> > name="save"
> > value="OK" id="fbbtn" class="btn" /></p>
> >            <p><input type="button" value="OK" disabled=true id="fbsb"
> > class="btn"  onclick="document.form1.action='/
> > s2t';document.getElementById('fbbtn').click(); this.disabled=true;" /
>
> >> </p>
>
> >            </form>
> > ====================
>
> > Right now I am running this code:
>
> > var allInput, thisInput, allImg, thisImg;
> > allInput = document.evaluate(
> >      '//inp...@value]',
> >      document,
> >      null,
> >      XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
> >      null);
> > for (var i = 0; i<  allInput.snapshotLength; i++) {
> >      thisInput = allInput.snapshotItem(i);
> >      if (thisInput.value == 'OK'){
> >        thisInput.click();
> >      }
> > }
>
> > It clicks the button but the webpage just refreshes itself instead of
> > doing what the button does when manually clicked.
>
> > Any suggestions to fix this so the button clicks as if manually done
> > is welcomed! Thanks in advanced.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "greasemonkey-users" group.
> > To post to this group, send email to greasemonkey-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > greasemonkey-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/greasemonkey-users?hl=en.
>
> > ____________________________________________________________________________________
> > Download thousands of great movies, for free!
> >http://click.lavabit.com/?r=MTc0
> > ____________________________________________________________________________________
>
> --
> cc | pseudonymous |<http://carlclark.mp/>

--

You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to greasemonkey-us...@googlegroups.com.
To unsubscribe from this group, send email to 
greasemonkey-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.


Reply via email to