Use window.location.href=''
in place of window.open('menu.html')
, window.open
will open a new window and that’s not what you want...
You can use too window.location.replace('menu.html')
, but this will replace the current page in the browser history, making it not possible to return to the page after clicking the button.
Option 1 window.location.href=''
:
<button type="submit" onclick="window.location.href='menu.html'">Login</button>
Option 2 window.location.replace()
:
<button type="submit" onclick="window.location.replace('menu.html')">Login</button>
Option 3, a button made link.
.btnlogin {
background:#000;
border-radius:4px;
padding:4px 6px;
color:#fff;
text-decoration:none;
}
<a href="menu.html" class="btnlogin">Login</a>
Face your question is hard to interpret. You have a
button
of the kind Submit, this type of button submits something, it is usually placed in aform
to submit it. If you put this function onclick in a Ubmit, the form is submitted, there will be no time to perform the function you want. You want to open a right menu, on the same page, on another page, what you really want to do?– LeAndrade
tries to use "<a href="menu.html"><button type="Submit">Login</button></a>"
– Vitor Hugo
Why did you use
<button>
and not<a>
?– Woss