On using Google I found that they are using onclick events in anchor tags.
In more option in google header part, it looks like normal a tag, but onclicking it doesn't get redirected but opened a menu. Normally when using
<a href='more.php' onclick='show_more_menu()'>More >>></a>
It usually goes to 'more.php' without firing show_more_menu()
, but I have show a menu in that page itself. How to do like google?
This question is related to
javascript
hyperlink
onclick
anchor
Use following code to show menu instead go to href addres
function show_more_menu(e) {_x000D_
if( !confirm(`Go to ${e.target.href} ?`) ) e.preventDefault();_x000D_
}
_x000D_
<a href='more.php' onclick="show_more_menu(event)"> More >>> </a>
_x000D_
You can even try below option:
<a href="javascript:show_more_menu();">More >>></a>
From what I understand you do not want to redirect when the link is clicked. You can do :
<a href='javascript:;' onclick='show_more_menu();'>More ></a>
Source: Stackoverflow.com