PDA

View Full Version : click() problem in firefox !!



reazrana
10-18-2007, 07:06 AM
hello

i hv a problem.



document.getElementById('s_' + route_id[x] ).click();


this works in IE fine but not in FF. i want this works when page is loaded. no mouse click is needed for that. it works in IE fine, but in firefox, no working

any solution?

jscheuer1
10-18-2007, 07:47 AM
The .click() object is non-standard. I think that one or two other browsers besides IE do support it, but FF is not one of them.

To answer your question, if what you want to fire is document.getElementById('s_' + route_id[x] )'s hard coded or its directly assigned by script (not created by addEventListener) onclick event, you can do (or something similar, depending upon the sort of event you are firing):


document.getElementById('s_' + route_id[x] ).onclick.apply(document.getElementById('s_' + route_id[x] ));

Otherwise, it could be fairly to very complicated, and depending upon what exactly you want to do, may not be possible via any type of click emulation. If there is any way to determine and execute whatever action you want to take other than by simulating a click, that would be the way to go.

I could be more specific if I saw your page.

reazrana
10-18-2007, 07:56 AM
hello John

thanks for ur reply.

but it's not working yet.

jscheuer1
10-18-2007, 08:02 AM
I did say it depended upon what you are actually doing. It isn't an exactly equivalent replacement for .click().

Please post a link to the page on your site that contains the problematic script so we can check it out.

reazrana
10-18-2007, 08:24 AM
i want to select a object during loading the page. for that i used .click() which is working in IE. but in ff it isn't.

ur solution not works in IE or FF.
in IE it says "object required".

jscheuer1
10-18-2007, 08:37 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.