jeudi 2 octobre 2014

A href not working when onclick works


Vote count:

0




Subject is a problem. Well I have, for example, this html



<a href="/en/pages/socials.aspx">Learn more</a>


It doesn't work. Okay, perhaps there are some invisible elements that don't allow to click on it. Here I add onclick property:



<a href="/ru/pages/socials.aspx" onclick="javascript:alert('Hi');">Learn more</a>


But now I see that "Hi" message appears (so <a> tag is clickable), but it doesn't change current page.


Well, ok. Now i'm changing javascript to:



<a onclick="window.location.href='/ru/pages/socials.aspx';return false;" href="/ru/pages/socials.aspx">Learn more</a>


and now it works as espected, but I'm looking for non-JS pure HTML solution.


Please, advice. Why <a> could be non-clickable for href, but with workable JS onclick event?



asked 2 mins ago







A href not working when onclick works

Aucun commentaire:

Enregistrer un commentaire