The page is reloading because browser is interpreting it as submit button. Default behaviour of submit button is to refresh. You can use the answer suggested by sfdcfox or can try the following: You can make the type attribute of your button as "button". Some browsers act like submit if type is not specified. <button class="btn-enter-panel" onclick="getRemoteName()" type="button">enter <i class="fa fa-long-arrow-right"></i></button> > Always specify the type attribute for a <button> element. Different > browsers use different default types for the <button> element. Src: https://www.w3schools.com/tags/tag_button.asp