.click on firefox based browser
Posted by: asktome
Date: November 26, 2011 02:04AM

Hi to all i want to simulate the .click() function for all Firefox based Browser.

All work good in IE if i use this function:
javascript:document.getElementById("BUTTON_ID").click();

But Firefox doesnt support that, i have found this articole here
i have load my page in kmeleon and inserct this into the url bar:

javascript:HTMLElement.prototype.click = function() {var evt = this.ownerDocument.createEvent('MouseEvents');evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);this.dispatchEvent(evt);} document.getElementById("BUTTON_ID").click();
But nothing is happened...how i can do that?

Hi!

Re: .click on firefox based browser
Posted by: asktome
Date: November 28, 2011 04:33AM

noone can help me? grinning smiley

Re: .click on firefox based browser
Posted by: JohnHell
Date: November 28, 2011 10:39PM

What does the Error Console say? (Tools menu)

P.S.: K-meleon is not Firefox based browser but Gecko based browser as Firefox ;)

EDIT: typo and PS



Edited 1 time(s). Last edit at 11/28/2011 11:29PM by JohnHell.

Re: .click on firefox based browser
Posted by: asktome
Date: November 29, 2011 06:59AM

The console always says that:
XML Parsing Error: undefined entity
Location: chrome://global/content/console.xul
Line Number 14, Column 1:<window id="JSConsoleWindow"
^
Hi!

Re: .click on firefox based browser
Posted by: JohnHell
Date: November 29, 2011 08:44AM

O_o that is what it says after clear it and run that code?

By the way, the code you posted, is the actual code you would like to run? I didn't pay much attention to it, but looks... not very functional...

I mean, if you have assigned an ID to a button, and you call that id, theoretically, works.

If your button, or link, or whatever, has the ID XXX and you type in the URL bar javascript:document.getElementById('xxx').click() It is enough to work



Edited 2 time(s). Last edit at 11/29/2011 08:50AM by JohnHell.

Re: .click on firefox based browser
Posted by: asktome
Date: November 30, 2011 03:18AM

Quote
JohnHell
O_o that is what it says after clear it and run that code?

By the way, the code you posted, is the actual code you would like to run? I didn't pay much attention to it, but looks... not very functional...

I mean, if you have assigned an ID to a button, and you call that id, theoretically, works.

If your button, or link, or whatever, has the ID XXX and you type in the URL bar javascript:document.getElementById('xxx').click() It is enough to work
.click() function dont work on gecko, i have to emulate the .click function smiling smiley

Hi!

Re: .click on firefox based browser
Posted by: JohnHell
Date: November 30, 2011 07:44AM

Works for me and I'm using K-meleon 1.1.6, that has an old Gecko engine (rv:1.8.1.23 Gecko/20090825) with javascript 1.8.1, just as I told with the button xxx example I told.

Re: .click on firefox based browser
Posted by: asktome
Date: November 30, 2011 11:34PM

Im using K-Meleon 1.6.0 and i can't switch to a minor release number becouse i'm using some macro language functions that can't be compatibile with previous version. Noone can test this with kmeleon 1.6? Just to understand if it dont work on this version or my pc are crazytongue sticking out smiley

Thanks to all!

Re: .click on firefox based browser
Posted by: JohnHell
Date: December 01, 2011 04:43AM

Work too (the example given by me of a page with a button with xxx).

I think we should see the full html/js code to see where exactly is the problem as the error given by you hasn't sense (for what you are trying), at least for me sad smiley

I'm going to edit this post, just to instruct you about some test just on this page smiling smiley

EDIT:

Curious, it works for input but not for a tags LOL

Ok, as I can do what I was going to do, just, in this page type in the url bar or copy and paste this:

javascript:alert(document.getElementsByTagName('a')[59].href)

What, as I said, is curious, you can click and "input", but not "a" link xD

I was going to tell you to use click to reply my quoting my message sad smiley

EDIT again:

Nah, nothing :/

For "a" tag says click is not a funtion. But as you need it for a button, calling it by getting its id, instead tag, with what I said, should work.



Edited 5 time(s). Last edit at 12/01/2011 05:06AM by JohnHell.

Re: .click on firefox based browser
Posted by: megaduu
Date: December 01, 2011 10:54AM

Well done ,learn more

K-Meleon forum is powered by Phorum.