0

I have a javascript link

<a href="javascript:hideSideBar();" style="color: #fcfcfc;" data-toggle="tooltip" data-original-title="Hide Comments" data-placement="right"> <span class="glyphicon glyphicon-remove"></span> </a>  

that calls this function

function hideSideBar(ID) {
    var selector = ".sidebar";
    if (ID !== undefined) {
        selector = "#" + ID + selector;
    }
    $(selector).hide("slide",{ direction: "right" });
    $(".sidebar-btn").show("slide",{ direction: "right" });
}  

that for some reason adds '#javascript:hideSideBar();' to the address bar.

this is the only place where it does that and I can't figure out why it does that or how to get rid of it?

artgb
  • 3,177
  • 6
  • 19
  • 36
  • Please add fiddle – artgb Oct 25 '17 at 15:32
  • Never use `href="javascript:..."` unless you are writing a bookmarklet. Either use a real link with a server side fallback and then event.preventDefault(); or use a button instead of a link. – Quentin Oct 25 '17 at 15:36
  • Try providing a [mcve]. I suspect the problem is caused by some other JS on the page. – Quentin Oct 25 '17 at 15:40
  • Quentin, I was able to use a button - thank you I'm still not sure why this happens but the button has the correct behavior and doesn't foul up the addressbar – Nikolay Roshtainsky Oct 25 '17 at 15:48

1 Answers1

0

I was able to achieve what I needed with this

<a href="javascript:hideSideBar();" class="btn btn-default" role="button"> <span class="glyphicon glyphicon-remove"></span> </a>