The role of the anchor is to jump to the designated place, the anchor can be used in with the name. We usually do not use the anchor like ##, if you want to keep the position, you can set Onclick event return false;
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
110 Points
37 Posts
<a href=#>X</a>?<a href=##>X</a>?<a href=###>X</a>?<a href=javascript:;>X</a>?<a href=javascript:...
Sep 26, 2016 01:09 AM|mqingqign123|LINK
a page if have scroll, a link have function, like below
if you click X, the pag will alert and the page will scroll to top.
if href keep blank, it will open new page.
so, want page keep position state, one method is return false.
if not use return false, use void(0) instead
someone also write :; like below.
use ### can also have the keep position
in fact, I often use
a little difference is if add target=_blank ( <a target=_blank href="###" onclick="alert('hellow');">X</a>) the page will open new,
but, <a href="#" target=_blank onclick="alert('hellow'); return false">X</a> not.
now, my question is :
why <a href="##" onclick=alert("hello">X</a> DO NOT keep position state.
Star
11464 Points
2439 Posts
Re: <a href=#>X</a>?<a href=##>X</a>?<a href=###>X</a>?<a href=javascript:;>X</a>?<a href=javascr...
Sep 27, 2016 03:30 AM|Yohann Lu|LINK
Hi mqingqign123,
The role of the anchor is to jump to the designated place, the anchor can be used in with the name. We usually do not use the anchor like ##, if you want to keep the position, you can set Onclick event return false;
Reference Code :
Best Regards,
Yohann Lu