473,672 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1866
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
2073
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 it goes straight to the redirect page 'test.html' which indicates that javascript is not enabled and it also does not display the header info. Can someone tell me why this is happening? <%@ Language=VBScript%> <%'get header info
16
2858
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 development. I have build some cross browser debuggers so my users can send me verbose debug dumps. I have some success but have come to a roadblock with the basic underlying JavaScript models. The only way to get a complete stack in IE is to use the...
3
11219
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 written on the client browser , like IE. To send a POST to web server to acknowledge its close event. However, I just think, web server and client browser is a TCP connection. And if the client browser is close and it imply the TCP socket is...
6
5224
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
1525
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 System.Web.HttpContextCurrent.Request.Browser.Type.ToUpper
6
3934
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 signal to server. This seems to be achievable with body unload events, but it is little too much, as even if user navigate within my site, this event will be generated, this can be avoided by handling onclick of each link, so that I'll know exactly...
4
3091
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. What I have found is that if the page in Frame2 fails to load and I get an error page. when I detect an error page I want to set frame2.location.href = "about:blank" and then write a temp error page until the server becomes available again. The...
4
2543
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 language="JavaScript"><!-- browser_version = parseInt(navigator.appVersion); browser_type = navigator.appName; if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) {
1
4147
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 ; Styleff_1024x768.css; Style_1280x1024.css ; Styleff_1280x1024.css ) I want to set css style file depends on resolution browser I wrote this script to detect type of browsers, but i don't have any idea
0
8506
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8649
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7482
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6261
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5725
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4251
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2098
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.