html - href="javascript:func()" vs href="#" onclick="javascript:func()" -


<a href="javascript:expand()">  , <a href="#" onclick="javascript:expand()"> 

what's difference?

i know href="#" more standard way nowadays it. problem have standard dropdown menu expands/collapses when user clicks on toggle.

if href="#" code below, whenever clicks on expand page scroll right top isn't acceptable user friendly point.

if use href="javascript:expand()" when user clicks expand, page doesn't move , ok.

so there problems if use href="javascript:expand()" instead? or how fix href="#" page doesn't scroll top whenever user clicks expand.

thanks.

edit: know question may have been asked before, i'm looking @ point of view. im asking suggestion rather explanation.

if javascript onclick event handler returns false, scrolling won't occur. can this:

<a href="#" onclick="expand(); return false;"> 

if onclick handler not return false, href link followed. in case of href="#", means scroll top of page.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -