Re-direct to one of two urls depending on the browser used?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
shaunguyver
Forum Newbie
Posts: 3
Joined: Wed Aug 15, 2007 8:46 am

Re-direct to one of two urls depending on the browser used?

Post by shaunguyver »

Hello all. I have a problem -

http://www.guyverdesign.com

The above url works perfectly in IE, but not in Firefox, however the following url


http://www.guyverdesign.com/new

... works perfectly in firefox but terribly in IE. How do I create an index page that re-directs to http://www.guyverdesign.com if the browser the user has is IE, and to http://www.guyverdesign.com/new if the user has Firefox? I'm sure I've seen this before but my googling has proved fruitless.

Thank you so much for (hopeful) responses!!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

... How about we NOT do that, and instead address the *actual* problem. Why would you have two different pages for two different browsers? What is the point, and what does it do for the other major browsers?
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

First off ... superdezign is right in saying fix the problem. Having the different pages for different browsers will cause all kinds of problems later on (especially for maintenance).
Main initial thought is the lack of CSS usage in the page. (Second one by the way is how accessible is this for the disabled ?).

Can you highlight the differences between the two pages so we could try to help. Is it a simple matter of the "tooltip help" when going over an image ? Have you tried the page on Safari (also available on windows) and Opera ?

To answer your question though in case someone else needs it...
get_browser could be used with a header('Location:page');
shaunguyver
Forum Newbie
Posts: 3
Joined: Wed Aug 15, 2007 8:46 am

Post by shaunguyver »

Your points are fair, but right now I am simply loking for a way for the user of the two major browsers to get a seemless site.

But of course fixing the problem so that there isn't any need for this get browser function would be better.

In http://www.guyverdesign.com/new the page uses ajax so that the pages load in a given area within the black space at the bottom of the site. In firefox this works fine, in IE it creates an inexplicable margin of about 200px at the bottom of the site.

In http://www.guyverdesign.com the page uses an iframe to load each page but it is set with a 100% width which requires a piece of jacascript in the head to set this. This works fine in IE but in Firefox creates an enormous amount of white space below the site.

So I suppose the real question is - How do I create a function where I can load external html pages into an area that can be 100% the width of the page that works perfectly in both firefox, ie and safari?

And also, your point about disabled users... do you think the text is too small? Or are there other problems?

Shaun Guyver
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

shaunguyver wrote: In http://www.guyverdesign.com/new the page uses ajax so that the pages load in a given area within the black space at the bottom of the site. In firefox this works fine, in IE it creates an inexplicable margin of about 200px at the bottom of the site.
Have you looked into Conditional Comments as a possible method of correction for IE ? In your file you could set CSS slightly different for IE. Not sure if this would solve the problem as it depends on how things work in Opera and Safari.
shaunguyver wrote: So I suppose the real question is - How do I create a function where I can load external html pages into an area that can be 100% the width of the page that works perfectly in both firefox, ie and safari?
CSS and I dread to say some possible CSS Hacks if needed. As it looks from initial brief examination as though you need javascript anyway using AJAX to fill a named div should work.
shaunguyver wrote: And also, your point about disabled users... do you think the text is too small? Or are there other problems?
I am no means an accessibility guru and indeed I am not saying there is anything wrong with the page. Text size initially is not something I think about as CTRL+ in Firefox tends to solve that :wink:. In general though the whole page is one big table. My understanding is that Screen Readers (For the blind) would find this difficult. An awful lot depends on target audience. One of the biggest "gripes" I have is that it is not easy as a programmer to experience sites as though we were disabled. As far as I know there are no free screen readers available so developers can test applications.
You may want to check for simple things with the Total Validator add-on for firefox and see what you get.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

CoderGoblin wrote:As far as I know there are no free screen readers available so developers can test applications.
Yes there are. The screen readers are free, but to get a voice that isn't annoying to listen to, you have purchase the different voices. I use one that can embed itself into Firefox. The other ones take over the whole computer.
shaunguyver
Forum Newbie
Posts: 3
Joined: Wed Aug 15, 2007 8:46 am

Post by shaunguyver »

The conditional comments are helpful, but how do I edit it to determine a firefox browser? Eg -

<!--[if Firefox]>
According to the conditional comment this is Firefox<br />
<![endif]-->

... also instead of text appearing how do I insert a function so that it will redirect an url?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

http://www.quirksmode.org/css/condcom.html wrote:Conditional comments only work in Explorer on Windows

Code: Select all

<!--[if IE]>
<style type="text/css">@import "inc/style.ie.css";</style>
<![endif]-->
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Re: Re-direct to one of two urls depending on the browser us

Post by AKA Panama Jack »

shaunguyver wrote:Hello all. I have a problem -

http://www.guyverdesign.com

The above url works perfectly in IE, but not in Firefox, however the following url


http://www.guyverdesign.com/new

... works perfectly in firefox but terribly in IE. How do I create an index page that re-directs to http://www.guyverdesign.com if the browser the user has is IE, and to http://www.guyverdesign.com/new if the user has Firefox? I'm sure I've seen this before but my googling has proved fruitless.

Thank you so much for (hopeful) responses!!
You DON'T!

You create the web site to work on BOTH instead of trying to program the site for specific browser versions by using QUIRKS in each browser. It's not that hard to create a website that works in every browser without coding for specific browsers.

Also, trying to program for different browsers is getting to be useless as most modern browsers can mask their ID to mimic other browsers. So trying to detect for a specific browser is useless. I have been to a few sites that check for Opera and they disable everything if Opera is being used. I just mask as IE and the site magically works. Programming for specific browsers is just plain silly and counter productive. Why counterproductive? Because you end up having to maintain multiple pages for different browsers and that is time consuming and usually the programmer stops maintaining everything but one page for one browser.

Just don't do it and create the site using web STANDARDS so it works on all browsers.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

shaunguyver wrote:In http://www.guyverdesign.com/new the page uses ajax so that the pages load in a given area within the black space at the bottom of the site. In firefox this works fine, in IE it creates an inexplicable margin of about 200px at the bottom of the site.
In Opera your NEW page puts a HUGE whitespace at the top of the page the height of the makepovertyhistory.org angle graphic. The original works just fine.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

superdezign wrote:
CoderGoblin wrote:As far as I know there are no free screen readers available so developers can test applications.
Yes there are. The screen readers are free, but to get a voice that isn't annoying to listen to, you have purchase the different voices. I use one that can embed itself into Firefox. The other ones take over the whole computer.
Opera comes with built-in Screen Reader support.
Post Reply