Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Why Does IE Choke on This?

Why Does IE Choke on This?
Thread Tools
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
Jun 22, 2005, 04:04 PM
 
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
Reply With Quote
Jun 22, 2005, 10:01 PM
 
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
Reply With Quote
Jun 22, 2005, 10:47 PM
 
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
Reply With Quote
Jun 22, 2005, 11:53 PM
 
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
Reply With Quote
Jun 23, 2005, 06:14 AM
 
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
Reply With Quote
Jun 23, 2005, 07:57 AM
 
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
Reply With Quote
Jun 24, 2005, 08:45 AM
 
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.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:17 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2