King_Karlssen Posted January 9, 2006 Share Posted January 9, 2006 I'm trying to create a standard button on my webpage, www.kingkarlssen.net, a button that links to another page. An Href isn't working. I could use a navigation bar, but thats my last resort. I need to tell it when some one clicks it ( onclick="..." ) to go to another page. I also tried to hotbox it but that only works with images. Maybe I need to put in some kind of return value option? Link to comment Share on other sites More sharing options...
Skemcin Posted January 9, 2006 Share Posted January 9, 2006 you mean a form button or an image button?can you paste the code that didn;t work so we can see what might be wrong? Link to comment Share on other sites More sharing options...
pulpfiction Posted January 9, 2006 Share Posted January 9, 2006 <HTML><HEAD><script language=javascript> function test() { location.href='http://www.google.com'; }</script></HEAD><body><INPUT type="button" value="Button" onclick="test();"></body></html> is this what you were looking for? Link to comment Share on other sites More sharing options...
chadmichael Posted January 9, 2006 Share Posted January 9, 2006 Although I'm not sure why it is designed this way, I think you need to set the location property itself to the url string. You are setting location.href. I understand that the href contains the string, but the way to make the page change is to set the location itself to the url string. ALSO, you could use the button tag rather than the input tag with the button attribute. I would do this because, in this case, you don't really have a form element which is what the input tag is, but this is all personal preference. Link to comment Share on other sites More sharing options...
zanfranceschi Posted January 10, 2006 Share Posted January 10, 2006 Try this:<HTML><HEAD><script language=javascript> function test() { document.location.href='http://www.google.com'; }</script></HEAD><body><INPUT type="button" value="Button" onclick="test();"></body></html> Link to comment Share on other sites More sharing options...
smiles Posted January 10, 2006 Share Posted January 10, 2006 your code is no matter , maybe another parts affected it , check the whole code carefully Link to comment Share on other sites More sharing options...
King_Karlssen Posted January 10, 2006 Author Share Posted January 10, 2006 Okay, that looks like it'll work, I wasn't sure how to make a function in javascript go to another page. what I was using was this <html><head><title>Home Page</title><body><form><a href="http://www.kingkarlssen.net"><input type="button", value="King Karlssen HomePage"></a></form></body></html> Link to comment Share on other sites More sharing options...
Skemcin Posted January 10, 2006 Share Posted January 10, 2006 even easier: <html><head><title>Home Page</title><body><form><input type="button" value="King Karlssen HomePage" onclick="document.location='http://www.kingkarlssen.net';"><br></form></body></html> Link to comment Share on other sites More sharing options...
King_Karlssen Posted January 10, 2006 Author Share Posted January 10, 2006 Cool thanks guys, you really know your stuff! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now