 |
 |
Why Does IE Choke on This?
|
 |
|
 |
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Code:
<a href="http://www.google.com/"><input type="button" value="Go to Google" /></a>
This button successfully takes me to Google in all browsers except IE for Mac. What in the world is wrong? I can't figure it out. Is it an IE-specific bug?
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Apr 2005
Status:
Offline
|
|
Originally Posted by selowitch
Code:
<a href="http://www.google.com/"><input type="button" value="Go to Google" /></a>
This button successfully takes me to Google in all browsers except IE for Mac. What in the world is wrong? I can't figure it out. Is it an IE-specific bug?
It's not an IE-specific bug. This may work in other browsers b/c they are figuring out what you mean - but that doesn't mean that this is proper code.
If you want to make sure that your code is going to work in the majority of browsers, write it correctly the first time.
Code:
<input type="button" name="google" value="Goto Google" onclick="location.href='http://www.google.com';" />
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Thanks, that's helpful. A follow-up: If I want to make sure the button works even if JavaScript is disabled, can I enclose the whole thing in an <a href=> tag?
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Apr 2005
Status:
Offline
|
|
Originally Posted by selowitch
If I want to make sure the button works even if JavaScript is disabled, can I enclose the whole thing in an <a href=> tag?
Wasn't this your original problem?
If all you're trying to do is create a link to another page/site, you would be better off simply using either CSS formatted text or an image. Buttons should be reserved for initiating a script or submitting a form rather than used as navigation.
As I said previously, if you use elements as they were meant to be used, you will run into less browser compatibility problems. Every element in HTML has a purpose, and it should be used accordingly.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Code:
<input type="button" name="google" value="Goto Google" onclick="location.href='http://www.google.com';" />
???
Why not just a FORM with a GET method - no javascript needed!
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
Originally Posted by Simon Mundy
Code:
<input type="button" name="google" value="Goto Google" onclick="location.href='http://www.google.com';" />
???
Why not just a FORM with a GET method - no javascript needed!
That should work in any browser, though it's a relatively obscure method of doing things. The code would look something like this:
Code:
<form action="http://www.google.com" method="GET"><input type="submit" value="Goto Google" /></form>
This said, why are you using a button for this? The functionality is just that of a link, so why not use a link?
|
|
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Originally Posted by Millennium
That should work in any browser, though it's a relatively obscure method of doing things. The code would look something like this:
Code:
<form action="http://www.google.com" method="GET"><input type="submit" value="Goto Google" /></form>
This said, why are you using a button for this? The functionality is just that of a link, so why not use a link?
Thanks for suggesting a do it using the <form> tag instead. That's clearly a better idea. The question of whether I should use a button or a link is an interesting one, since in this case I want to both close the existing window and return to an earlier page (it's for an enlargement of an image).
Thanks for your input, everyone. Clearly my brain was a little foggy when I wrote this, because the solution seems pretty obvious now.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|