January 22, 2003

Buttons, Alerts, & Links

I tried making a button that had an alert and also sent you somewhere. I've gotten the alert to work, but the link doesn't.
Here is how I did it:


<a href="page2.html" onClick="alert('What am I doing wrong?');">

<input type="button" name="link" value="Click Here">

</a>


If anyone knows what I am doing wrong or if there is a better way to go about this I would be much obliged.

Eamon

Posted by at January 22, 2003 05:44 PM | TrackBack
Comments

try this

that'll work.

Posted by: RyanN on January 23, 2003 08:31 AM

sorry, i forgot to use special characters so my code wouldn't execute. Here you go.

<input type="button" name="link" value="Click Here" onClick="alert('What am I doing wrong?');location.href='http://www.google.com/'">

Posted by: RyanN on January 23, 2003 08:34 AM

You didn't provide the full context, but the button also has to be enclosed within form tags for it work consistently.

Posted by: Liz on January 27, 2003 04:59 PM