Are you getting any messages in the Error Console?
What happens if you insert an alert just before calling fireEvent?

On 2010-03-01 09:16, FedeWP wrote:
Hi everyone,

I want to simulate a link click in Firefox using Javascript. Directly
navigating to the address is not enough in my case.
I've been struggling and making research about this for quite a while now,
read many forums and posts.
I try a specific code in a Javascript console and it works, but when I use
the same code on a GreaseMonkey script the link is not clicked.

Here goes the code I'm trying:



                 link = document.getElementById('link');
                 alert('link = ' + link);
                 function fireEvent(obj,evt){
                     alert('fireEvent');
                     var fireOnThis = obj;
                     if( document.createEvent ) {
                            alert('createEvent');
                         var evObj = document.createEvent('MouseEvents');
                         evObj.initEvent( evt, true, false );
                         fireOnThis.dispatchEvent(evObj);
                     } else if( document.createEventObject ) {
                         fireOnThis.fireEvent('on'+evt);
                     }
                 }
                 fireEvent(link, 'click');



The link element is obtained correctly but the alert('fireEvent') never gets
triggered.

Is my approach correct or should I try other way?
Does Firefox somehow prevents clicking a link programatically?

Any help on this would be greatly appreciated.

Thanks in advance.

Regards,

Fede
--
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