metadata 0 Posted August 8, 2012 Report Share Posted August 8, 2012 (edited) I am trying to figure out the best way to display a button on a page that will open a new page on clicking. I have a function set up using JS that once the button is clicked will call the function and then I can enter the code there to do the redirection. I just need to find some documentation on writing this code. Is it also possible to make the button itself a link so that by clicking on the button you would effectively be clicking on a link as well? (I've already done redirection this way) Thanks Edited August 8, 2012 by metadata Quote Link to post Share on other sites
mru21 0 Posted August 8, 2012 Report Share Posted August 8, 2012 I think this may help?http://www.w3schools.com/html/html_links.asp Quote Link to post Share on other sites
metadata 0 Posted August 8, 2012 Author Report Share Posted August 8, 2012 (edited) No that's just how to use links, which I understand. I'm trying to write a function in JavaScript where when a user clicks on a button it automatically sends them to another page (such as an order form page). I'm trying to figure out where I can find the documentation on writing the code inside the JS function to have to browser open up the new page. Below is a brief example of what I'm trying to do in the code: <!DOCTYPE html> <html><head> <script type="text/javascript">function orderPage(){ }</script> </head><body> <button type="button" onclick="orderPage()">Order Now</button> </body> </html> Edited August 8, 2012 by metadata Quote Link to post Share on other sites
mru21 0 Posted August 8, 2012 Report Share Posted August 8, 2012 like this<form><input type="button" value="Put Your Text Here" onClick="window.location.href='http://www.hyperlinkcode.com/button-links.php'"></form> Quote Link to post Share on other sites
metadata 0 Posted August 8, 2012 Author Report Share Posted August 8, 2012 I see, yes that works. thanks! Quote Link to post Share on other sites
ShadowMage 94 Posted August 8, 2012 Report Share Posted August 8, 2012 What you're looking for is the location object. If you want to maintain browsing history, use the assign() function. This will enable the user to hit the Back button to get back to the previous page. The replace() function replaces the current page in the history. For example, the user is on Page A. Then goes to Page B which has your button on it. The button takes the user to Page C. If assign() is used to get to Page C, hitting Back will take the user back to Page B. If replace() is used, it will take the user to Page A, since Page B was replaced in the history by Page C. I am not sure how modifying the href attribute handles history, but I would assume it would act like replace(). Quote Link to post Share on other sites
metadata 0 Posted August 8, 2012 Author Report Share Posted August 8, 2012 Yes I like that much better, gives more options in the handling of direction from the current page. Thank you that was what I was looking for. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.