Teammates: Use href="javascript:;" to indicate anchor tags without link

Created on 25 Jun 2017  路  4Comments  路  Source: TEAMMATES/teammates

<a href="#">Text</a>

The above is commonly used such that Text gains the appearance of a link while it does not actually link anywhere. However, this is the wrong method because # actually links to the top of the web page. The correct way to suppress such link is with href="javascript:;".

P.S. Of course, there might be cases where the intention _is_ to go to the top of the page. This needs to be examined case-by-case.

a-CodeQuality help wanted t-HTML

Most helpful comment

@VamsiSangam: @amarlearning was right, it was the $ prepended to it that caused trouble. href="javascript:;" alone does not have any drawback like that.

All 4 comments

Taking this one!

@wkurniawan07 , using href="javascript:;" might cause redirection to page not found on clicking it. Please have a look at #7206

@VamsiSangam not sure but I guess you removed href="$javascript:;" and @wkurniawan07 is asking to add href="javascript:;". Maybe in your case, this $ might be causing problem. Code link

@VamsiSangam: @amarlearning was right, it was the $ prepended to it that caused trouble. href="javascript:;" alone does not have any drawback like that.

Was this page helpful?
0 / 5 - 0 ratings