javascript - How can I make a button redirect my page to another page? -
this question has answer here:
- how create html button acts link? 26 answers
i have been trying following:
<form action="/home" class="inline"> <button class="float-left submit-button" >home</button> </form> it seems work goes page "/home?"
is there better way me make button inside form make page go new location?
just add onclick event button:
<button onclick="location.href = 'www.yoursite.com';" id="mybutton" class="float-left submit-button" >home</button> but shouldn't have inline that, instead, put in js block , give button id:
<button id="mybutton" class="float-left submit-button" >home</button> <script type="text/javascript"> document.getelementbyid("mybutton").onclick = function () { location.href = "www.yoursite.com"; }; </script>
Comments
Post a Comment