I have a onclick event for a href , but if a define a rel the function is not getting called
<a href="http://somewebsite"
onclick="javascript:someFunction('somevalue');"
name="top"
rel="somevalue">testing </a>
If I remove the rel
property the onclick is working just fine.
What's up with that?
I'm not sure this is really an answer, but really more of a debugging diagnostic. Plus, it was getting a bit long for use in the comments section.
There are no JS errors for me in either Chrome 7 or FF 3.6.8
There are no apparent unclosed quotes in the anchor tag
While the rel tag is not directly supported by any modern browser (but rather used by search spiders), the consensus is that it shouldn't affect events. In fact, per some user comments, such @James Kovaks, it works fine in his tests .
From the Chrome JS console, the function trackForGA is visible, and executable without error.
Attaching an event with jQuery, and then clicking, fires the event as expected. This tells us the click event is in fact being fired by the browser.
code:
$('#countrytabs li:first').click(trackForGA); // click overview tab
Suggested next steps:
Also, you never need to specify " javascript:
" in an onclick. The only thing that can follow is JavaScript.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.