473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Browser detect problem

I'm using a script to detect which browser is using in order to include
the correct stylesheet but on this one page
(http://korndragon.com/ffa5.php) It thinks I'm using Internet Explorer
when I'm really using FireFox. I have the same script included on all
pages on my site and it's never messed up before. In fact It's included
inside the nav, so nothing was changed.

The script itself: http://korndragon.com/style.php (view source and you
can see the comment of which stylesheet is being used)

The source: http://www.sitepoint.com/article/bro...uck-php-rescue

Anyway, it's just that one page that it's included on thinks I'm using
Internet Explorer (I've asked others and they said it's doing the same
thing) I included the script (style.php) at the top of the page so it's
easier to find the commented source.

Any ideas?

Thanks in advance.

Jun 7 '06 #1
4 1856
KoRnDragon:
I'm using a script to detect which browser is using in order to include
the correct stylesheet but on this one page
(http://korndragon.com/ffa5.php) It thinks I'm using Internet Explorer
when I'm really using FireFox.


Search for (Internet Explorer) conditional comments.

--
Jock

Jun 9 '06 #2
I'm using FireFox when it does that though. I wouldn't be having a
problem if I was using IE and it thought I was using IE. I'm using
FireFox and it thinks I'm using IE.

Jun 12 '06 #3
On 07/06/2006 20:06, KoRnDragon wrote:
I'm using a script to detect which browser is using [...]
Server-side? Good grief! It's bad enough trying to perform browser
detection client-side.
in order to include the correct stylesheet but on this one page
(http://korndragon.com/ffa5.php)
You would be better off rewriting that to trigger 'Standards' mode
(preferably by using, and authoring to, the Strict HTML document type),
and writing both valid markup and CSS (you have managed neither). Use a
decent browser like Opera or Firefox, and fix-up as necessary for IE.

If you rely on browser quirks to render your site, you are bound to
encounter problems. Writing different style sheets for various browsers
requires unnecessary effort, makes ongoing maintenance more taxing, and
you have no chance of coping with all user agents that might visit your
site. The point of conforming with interworking standards and guidelines
is to eliminate all of that[1].

[snip]
The source: http://www.sitepoint.com/article/bro...uck-php-rescue


Browser detection is unreliable, especially server-side. User agents
spoof others; Microsoft started it all. It is an inescapable fact.
Making a site functionally dependent upon browser detection is a serious
mistake.

[snip]

Mike
[1] I don't pretend that conforming to standards is a panacea,
but it is surely a better starting point than browser
detection, or writing unnecessary hacks.

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Jun 12 '06 #4
KoRnDragon:
I'm using FireFox when it does that though. I wouldn't be having a
problem if I was using IE and it thought I was using IE. I'm using
FireFox and it thinks I'm using IE.


I realise that. I was suggesting that you could use conditional
comments to serve Internet Explorer-only content (including styles
overruling non-Internet Explorer styles). Other browsers should treat
the content as a comment, since that is what it is as far as HTML4.01
is concerned.

That said, browser detection is not only doomed to failure but also
probably a mistake. As Michael Winter has pointed out, moving browser
detection based on the User-Agent header from client-side to
server-side does not overcome any of its problems, because browsers
still pretend to be each other. The mistake, I think, is making more
work for yourself than you really need.

--
Jock

Jun 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: AMC | last post by:
Hi, I have the below code in an asp page. When I run this page in IE or Opera it correctly displays the header info and does not redirect me to 'test.html'. However, when I run this in Netscape...
16
by: Java script Dude | last post by:
To all Mozilla JS Guru's (IE dudes welcome), I have spent the last three years developing complex DHTML applications that must work in IE 5.5sp2+ but I use Mozilla 1.3+** to do all my...
3
by: Denon | last post by:
How to trap browser close event in SERVER side? I read a lot of forum message, it talk about onclose(), onunload() and even onbeforeunload() event. However, all of theses are based on javascript...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
2
by: Sergey Poberezovskiy | last post by:
Hi, Simple question: I developed an ASP.Net application that runs under IE. Now for all other browsers I display a message that the application runs under IE: If Not...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
4
by: sid | last post by:
"about:blank" oepns new browser window I am writing a webpage that will run on other machines that I may or may not know about. My page is framed where frame1 controls the content of frame2. ...
4
by: m4ttyh2007 | last post by:
I figured i could easily solve my problem if i used a detectin script so a differant CSS could be used for each browser. So i found this: <!-- CSS Browser Detect BEGIN --> <script...
1
by: Grzegorz Klimsa | last post by:
Hi ! I have a problem wiht detecting resolution of client web browser I prepare several files of css style for different browsers and different resolutions, (such as : Style_1024x768.css ;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.