Click to See Complete Forum and Search --> : Checking browser type w/o javascript?
DJRobThaMan
10-21-2005, 07:55 PM
Hi,
Is there any way to check for the browser type without using javascript? I currently have my index page checking to see if it is ie (with javascript) and re-routing to another page (with javascript) if it is. Can I do this in some other way so that all users' browsers (even those with old versions of browsers and non-javascript-enabed browsers) can be detected and then re-routed.
Thanks
NogDog
10-21-2005, 09:28 PM
Take a look at http://us2.php.net/function.get-browser (and note the configuration info a couple screenfuls into the page).
Stephen Philbin
10-21-2005, 09:35 PM
Assuming you're using PHP, there's also $_SERVER['HTTP_USER_AGENT'] that you can mess about with.
NogDog
10-21-2005, 09:40 PM
Heh, forgot which forum I was in. (Thought I was in the PHP forum.) :)
Stephen Philbin
10-21-2005, 09:47 PM
lol.
You wouldn't believe how often I do that. ;)
DJRobThaMan
10-22-2005, 11:55 AM
Awesome,
Thanks guys. I'm not farmiliar at all with php but I'll check it out
Stephen Philbin
10-22-2005, 02:33 PM
Well there's a chance you might not have PHP available, but you might have a different server side language. If so, then asking about them in their respective forums should get you all the help you need. ;)
felgall
10-22-2005, 05:53 PM
Of course anyone can set the User Agent to whatever they like so it can't be relied on 100%. Some browsers make it easy to change it, Opera gives you a choice of several. Even with IE it is a simple registry edit to change it.
Stephen Philbin
10-22-2005, 10:21 PM
Aye. Making your applications dependant on browser detection is generally considered a very bad idea. Ok for adding non essential features, but for core functionality, a big no-no.
DJRobThaMan
10-22-2005, 11:08 PM
Well, I was having a major problem with a few minor things in IE. The margins weren't being rendered correctly (i fixed that by using borders instead though) but the major thing is no matte rhow I tried the banner on the top of all the pages in the site would not look the same in both IE and anything else, no matter how hard I tried. For some reason i needed to adjust the position of the jpg's by 4 pixels from the top (I think it was 4 anyway) for IE and for anything else it would be perfect. I also had to reposition a table I had that was positioned absolutely.
I know it's not a great idea to have separate site for separate browsers, but I want to show this thing to the person I'm doing it for as soon as possible, and doing this allows me to do that.
JPnyc
10-22-2005, 11:40 PM
You can use the !important hack to get round that. Put the style that you want for non IE browsers 1st, with the important keyword. THen put the IE style. IE doesn't understand the command so it will use the last setting, and the other browsers will use the 1st.
NogDog
10-23-2005, 01:02 AM
Just in case: make sure you're using a doctype for your pages so that IE is not in quirks mode. (One major effect of not using a doctype is that IE renders the box model incorrectly. Your comments about margin problems made me wonder if this could be the source of your problem.) See http://www.w3.org/TR/html4/struct/global.html#h-7.2 and http://www.w3.org/QA/2002/04/valid-dtd-list.html for more info.
DJRobThaMan
10-23-2005, 01:15 PM
I just added the doctypes to the main page of the site and it had really interesting results. The images are in the same place in all browsers now (which is good) but this table I have floating around is definitely in two different areas and all my borders just got a lot wider. I think this really helps though. I think I can fix all the quirks.
Thanks a lot