By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Redirect to another page with button click

Decahedron
P: 1
how do I get a button to open another page - I have this

<button type="button">Buggy Whipp Bio</button>

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

Any help would be appreciated
Nov 18 '08 #1
Share this Question
Share on Google+
12 Replies


acoder
Expert Mod 15k+
P: 16,027
If you want to avoid JavaScript, then use a submit button and set the action to the page you want to redirect to:
Expand|Select|Wrap|Line Numbers
  1. <input type="submit" value="Redirect">
Of course, you shouldn't be submitting a form to redirect, so use JavaScript, or a link.
Nov 19 '08 #2

clain
P: 79
Hey do this onclick="location.href='your_redirectionpage.html' " enjoy
Dec 1 '08 #3

acoder
Expert Mod 15k+
P: 16,027
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".
Dec 1 '08 #4

clain
P: 79
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?
Dec 1 '08 #5

acoder
Expert Mod 15k+
P: 16,027
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.
Dec 1 '08 #6

clain
P: 79
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="somthing.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...
Dec 1 '08 #7

acoder
Expert Mod 15k+
P: 16,027
@clain
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.
Dec 2 '08 #8

eWish
Expert 100+
P: 971
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
Dec 2 '08 #9

clain
P: 79
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
Dec 4 '08 #10

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

P: 22
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,
Apr 2 '19 #12

P: 18
try this code for redirect to another page
Expand|Select|Wrap|Line Numbers
  1. <button onclick="location.href = 'your Url';" id="myButton" class="float-left submit-button" >Buggy Whipp Bio</button>
May 23 '19 #13

This discussion thread is closed

Replies have been disabled for this discussion.