The most we can use when making a Web page is a tag hyperlink.
But sometimes you need to use both the href and the onclick attribute in A and we'll analyze it and have different effects under different browsers.
1 Order
IE 6:href Trigger after onclick first
Other browsers trigger the href after triggering Onlick first
2 href= "javascript:xxx ()"
Cannot pass in this as a parameter
OnClick can
<a href= "Javascript:alert (' href event ');" onclick= "clickevent (this);" >
3 Priority Firing method if return false causes the latter event not to be triggered
Like what
<a href= "Javascript:alert (' href event ');" onclick= "clickevent (this); return false; " >
4
<a href= "#" > will cause the page to be anchored to the bookmark location,
5
Because of the reason of 1 and 4
At the same time there are <a href= "#" and the onclick in the IE6 because the page was re-loaded because of the href, causing the onclick event to be discarded by the browser.
6 Summary:
1) When you do not need to pass this as the parameter of the method, it is recommended
Use only href= "JavaScript:"
2) If you need to use this parameter, it is recommended
<a href= "javascript:void (0)," onclick= "dosomthing (This)" > as the following column sub. We need a at the first and second click to access the href after the 3rd time to access another address
var href=0
function Clicka (obj)
{
if (href==2)
{
Obj.href= "HTTP://WWW.86P.COM/?QC";
}else
{
href++;
}
return true;
}
<a href= "http://www.fxxz.com/" Target=_blank id= "Showa" onclick= "Clicka (This)" > Open high Speed Download </a>
The problem priority level used by the href and onclick in the Html a tag