How can I make a button redirect my page to another page?

This question already has an answer here:

  • How to create an HTML button that acts like a link? 27 answers

  • Just add an onclick event to the button :

    <button onclick="location.href = 'www.yoursite.com';" id="myButton" class="float-left submit-button" >Home</button>
    

    But you shouldn't really have it inline like that, instead, put it in a JS block and give the button an 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>
    

    尝试

    <button onclick="window.location.href='b.php'">Click me</button>
    

    只是另一种变化:

        <body>
        <button name="redirect" onClick="redirect()">
    
        <script type="text/javascript">
        function redirect()
        {
        var url = "http://www.(url).com";
        window.location(url);
        }
        </script>
    
    链接地址: http://www.djcxy.com/p/36552.html

    上一篇: 如何链接两个HTML页面和一个按钮?

    下一篇: 我怎样才能让一个按钮重定向我的网页到另一个页面?