/    Sign up×
Community /Pin to ProfileBookmark

Browser Detection

I have a website that has a splash page and a home page. I wanted to make it so that the splash page holds a variable that detects what kind of browser the user is using, and then when they click on the link to lead to the main page, a function will activate immediately that will check to see if the user has IE 6.0, and if they do then print one thing. Anything else will just act normal.

I tried using PHP’s Include, but this actually transported the entire page into the other page, when all I want to bring over is the variable that holds what browser the user has.

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@temp_user123Jul 03.2007 — The only information PHP has access to which would hold any information concerning the browser would have to come from the CGI Request header which every browser sends when connecting to a server. For example:

$_SERVER['HTTP_USER_AGENT']

Otherwise, JavaScript would have to be used to gather and transmit additional information about the browser.
Copy linkTweet thisAlerts:
@felgallJul 03.2007 — Of course those are user enterable fields that can contain anything. Most times the user agent is set to report the browser as Internet Explorer regardless of which browser it is.
Copy linkTweet thisAlerts:
@temp_user123Jul 03.2007 — Is that all you can do is pooh-pooh what other people post? Do you ever actually try to provide solutions? ...or just criticisms? I'm not saying what you say is incorrect, but it is not helpful either.
Copy linkTweet thisAlerts:
@felgallJul 03.2007 — You can identify Internet Explorer by using IE conditional comments in HTML or JScript. You can't positively identify any other browser since the other browsers all try to follow the standards reasonably closely. With the exception of IE there is never any reason to know which browser it is except for statistical purposes anyway and that info is captured in your log.
Copy linkTweet thisAlerts:
@temp_user123Jul 03.2007 — Of course, as already pointed out by mr felgal, I've been given to understand that you can't depend upon what is recorded in your log because such information can be spoofed anyway.
Copy linkTweet thisAlerts:
@felgallJul 03.2007 — With enough visitors the stats on which browsers they are using should be reasonably accurate because few people spoof their user agent in such a way that the huge amount of code the stats program use to analyse it can't figure out at least approximately what browser they are using. Since it is only stats the exact numbers don't matter anyway since you only really need to know which browsers your visitors are using and not whether there are 1000 or 1001 visitors using a particular browser.

When it comes to anything other than stats it doesn't really matter which browser they are using - what you care about is whether the particular command you want to use is supported or not.
Copy linkTweet thisAlerts:
@temp_user123Jul 03.2007 — ... [COLOR="Red"][B]few people [/B][/COLOR]spoof their user agent ...[/QUOTE]
There's the real point I was hoping you'd finally deign to actually mention.

Just because a thing can be done does not mean it will be done.

Too many nay-sayers give false impressions in the first place.

There's a far cry from that to what you first stated:
Of course those are user enterable fields that can contain anything. [COLOR="Red"][B]Most times [/B][/COLOR]the user agent is set to report the browser as Internet Explorer regardless of which browser it is.[/QUOTE]
Copy linkTweet thisAlerts:
@felgallJul 03.2007 — Most people use a built in spoof option to identify their browser as Internet Explorer regardless of what browser it is they are actually using in order to allow their browser to run badly written code that has been set up to only run in Internet Explorer. The appName reporte as Internet Explorer and the userAgent contains the expecte MSIE references. The useragent usually also contains something that can be used with sufficient analysis to allow the actual browser to be determined. This requires an in depth analysis of the useragent to work out what browser it really is. Such analysis is performed server side by stats programs.

Most times the user agent is set to report the browser as Internet Explorer regardless of which browser it is but few users spoof the useragent in such a way that by passing the useragent through the hundreds of lines of code that stats programs use that the stats program doesn't get some indication of what browser it really is.

Other than for stats programs what browser it is doesn't matter since all that matters is whether the browser does or doesn't support a certain command and even if the current version of a browser doesn't the next version might.
Copy linkTweet thisAlerts:
@temp_user123Jul 04.2007 — You can spout on, if you feel driven to have the last word, but you're not really making any point worth paying much attention to. Though I grant there isn't much reason for personal server-side code to care what browser is on the other end of the connection, your reasons (justifications) to that effect don't hold water.
×

Success!

Help @Ascendancy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...