Redirect to another page with button click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Decahedron
    New Member
    • Nov 2008
    • 1

    Redirect to another page with button click

    how do I get a button to open another page - I have this

    <button type="button">B uggy Whipp Bio</button>

    i need it to bring a user to buggy whipp bio.html

    Any help would be appreciated
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    If you want to avoid JavaScript, then use a submit button and set the action to the page you want to redirect to:
    Code:
    <input type="submit" value="Redirect">
    Of course, you shouldn't be submitting a form to redirect, so use JavaScript, or a link.

    Comment

    • clain
      New Member
      • Feb 2007
      • 79

      #3
      Hey do this onclick="locati on.href='your_r edirectionpage. html'" enjoy

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Yes, that would be the JavaScript method of redirecting to another page.

        You can also use the button tag as a submit button by specifying type="submit".

        Comment

        • clain
          New Member
          • Feb 2007
          • 79

          #5
          yeah... but the submit buttom method wil have a posting and should have a form tag.. but this simple line of java script is worth while .. no extra fuss no posting.. jsut one click redirecting SIMPLE isn't it?

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Yes, I agree and if this had been posted in the JavaScript forum, that's exactly what I would have suggested.

            If you want to avoid JavaScript, or have users who may have JavaScript disabled, then you're left with the option of a link or a submit button.

            Comment

            • clain
              New Member
              • Feb 2007
              • 79

              #7
              But Mr Decahedron is using <button> tag so the only option for redirection is onclick redirect... now he have to change the whole code to
              <form action="somthin g.html" >
              <input type="submit" >
              </form>

              ??

              its a lot more tag and you changed the whole <button> tage to 2 tages extra.. and a posting which would be a burden for the server...

              i dont think that there would be people who disable javascript... in this web 2 world.. where everything work on javascript and Ajax...

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by clain
                i dont think that there would be people who disable javascript... in this web 2 world.. where everything work on javascript and Ajax...
                That's not quite true. A lot of people for a number of reasons have JavaScript disabled or choose not to enable JavaScript, e.g. using the NoScript Firefox addon, or even do not support it. A web page should work without JavaScript and JavaScript should not be used for basic functionality on the page. JavaScript can be used to enhance the page for those who have enabled it. The exception is when you know your users, e.g. in an intranet or logged in staff in your company.

                Comment

                • eWish
                  Recognized Expert Contributor
                  • Jul 2007
                  • 973

                  #9
                  I am one who has the JavaScript disabled. It is interesting how many pages rely on it. Sometimes it is a hassle without it, but for the most part I like it better without JavaScript.

                  --Kevin

                  Comment

                  • clain
                    New Member
                    • Feb 2007
                    • 79

                    #10
                    I accept your point "accorder" ... for security reason we may disable it in a intranet of an organization.

                    if Mr Decahedron don't have any trouble in using JavaScript then,let he use it... rather that a lot more posting and a form..

                    and Kevin u missed a beautiful web world without JavaScript

                    Comment

                    • sunny0070
                      New Member
                      • Jul 2012
                      • 1

                      #11
                      to redirect on another page you use
                      <button onclick="window .location.href= 'buggywhippbio. html'">Buggy Whipp Bio</button>

                      Comment

                      • gosai jahnvi
                        New Member
                        • Apr 2019
                        • 22

                        #12
                        you can use this code to redirect on another page:

                        <button onClick="window .location='page _name.html'" >click me</button>

                        i hope so it will help for you.
                        thank you,
                        Last edited by Rabbit; Apr 2 '19, 04:56 PM. Reason: external link removed per forum policy

                        Comment

                        • AjayGohil
                          New Member
                          • Apr 2019
                          • 83

                          #13
                          try this code for redirect to another page
                          Code:
                          <button onclick="location.href = 'your Url';" id="myButton" class="float-left submit-button" >Buggy Whipp Bio</button>

                          Comment

                          Working...