How to redirect page on button click event

后端 未结 4 730
-上瘾入骨i
-上瘾入骨i 2020-12-31 13:49

I am using a button on my form. How do I link to another web page/file when clicking on that link? Here is the code I tried, but does not work.

相关标签:
4条回答
  • 2020-12-31 14:06

    Try this

      <nav>
        <ul>
          <li><a href="#">button</a></li>
        </ul>
      </nav>
    

    and this the css

    nav
    {
        position:fixed;
        bottom:350px;
        left:600px;
    }
    
    nav ul ul {
        display: none;
    }
    
    nav ul li:hover > ul {
        display: block;
    }
    
    nav ul {
        background: #FFD700; 
        box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
        padding: 0 20px;
        border-radius: 10px;  
        list-style: none;
        position: relative;
        display: inline-table;
        color:black;
    }
    
    nav ul:after {
        content: ""; clear: both; display: block;
    }
    
    nav ul li {
        float: left;
    }
    
    nav ul li:hover {
        background:     #FFD700;
        color:white;
    }
    
    nav ul li:hover a {
        color:black;
    }
    
    nav ul li a {
        display: block; padding: 25px 40px;
        color: maroon; text-decoration: none;
    }
    
    nav ul ul {
        background:     #CFB53B;border-radius: 0px; padding: 0;
        position: absolute; top: 100%;
    }
    
    nav ul ul li {
        float: none; 
        border-top: 1px solid #6b727c;
        border-bottom: 1px solid #575f6a;
        position: relative;
    }
    
    nav ul ul li a {
        padding: 15px 40px;
        color: #fff;
    }   
    nav ul ul li a:hover {
        background: #996515;
    }
    
    0 讨论(0)
  • 2020-12-31 14:07

    set the url you want to go in <form> action attribute. then use a submit instead of button.
    Here is an example.:

     <form action="http://google.com">   
        <input type="submit" value="Google">
     </form>
    
    0 讨论(0)
  • 2020-12-31 14:15
    <input type='button'value='back' class="btn" onclick="document.location.href='RiskAssessmentMain.aspx';"/>
    

    Try it: http://jsfiddle.net/wzy4B/

    0 讨论(0)
  • 2020-12-31 14:19

    You Can try this one

    <script>
          function open_win() {
               window.open("http://www.google.com")
          }
    </script>
    

    Or you can also Do it like this

    <script>
           function openWin() {
                myWindow=window.open('','','width=200,height=100');
                myWindow.document.write("<p>This is 'myWindow'</p>");
                myWindow.focus();
           }
    </script>
    
    <input type="button" value="Open window" onclick="openWin()" />
    
    0 讨论(0)
提交回复
热议问题