Jump to content

OnClick button fuctions


King_Karlssen

Recommended Posts

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...