http://jsfiddle.net/HVGre/1/ - test link.
I have an html link on my page that I need to dynamically click. This works fine with .click () in IE, but does not work in firefox. I canβt change the link to the button, so this is not an option, it should be href.
<a href="javascript:alert('!');" id="myHrefLink">My HREF Link</a> <script> document.getElementById("myHrefLink").click(); </script>
Is there a good way around this in firefox? I can use jQuery if this opens up any possibilities.
I am not going to assign an event handler by reference, I just need to click the link dynamically using javascript (without this manually using the mouse).
I cannot change the functionality of the original link. He must remain as he is.
EDIT:
It seems that the problem with this code in Firefox is that the link does not have an onclick event and has the code referenced via href, or else NOT onclick (in the example here the code is in href, in my actual href code is installed only on "#", however the link somehow causes other actions when clicked, do not ask me how strange integration with flash with the plupload tool is).
<a href="javascript:alert('This works!');">Click me dynamically</a>
VS
<a href="#" onclick="alert('This works!');">Click me dynamically</a>
The second example is solid and works in all browsers when the click () function is launched, however I need the first of these two to work without changing the dynamic or any other connection. Any smart ideas?
source share