click() not working in Chrome
I have code like
1: var link = document.getElementById("myLink");
2: link.click();
and it is working in all browsers (really tested in IE8 and FF9) but not in Chrome.
Stackoverflow has three questions about this issue without workaround.
http://stackoverflow.com/questions/5015893/onclick-parent-getelementbyid-click-not-working-in-chrome
http://stackoverflow.com/questions/1938356/chrome-browser-action-click-not-working
http://stackoverflow.com/questions/7857289/click-not-working-in-chrome
People speak about some security limits.
And voila – solution:
1: var link = document.getElementById("myLink"); //existing code
2: $(link).click();
or pure jQuery style:
1: $("#myLink").click();
jQuery rules!!
Filed under: javascript • jquery
Like this post? Subscribe to my RSS feed and get loads more!

Leave a Reply