browser detecter
PostPosted: Mon Jan 19, 2004 4:58 am
by Mr. Rogers
For my site, I have 2 versions of it; one for internet explorer and one for mozilla/netscape, because each one renders frames differently. i was wondering if there is a java script or something i could put on my index page that would detect what browser the person is using and automaticly take them to the right page when they click the enter button?
PostPosted: Mon Jan 19, 2004 5:13 am
by LorentzForce
i wouldn't use javascript, cos which if i think correctly would make the site go elsewhere, which in mozilla's eyes would make it a site that'd be blocked. you're much better off with php in this opinion, because then you can use the meta that changes pages without mozilla hating it.
regardless, look for environment variables. they are provide lots of info about the client who visits your site e.g. IP address, reference page, and their browser.
PostPosted: Mon Jan 19, 2004 11:21 am
by shooraijin
I agree with Lorentz; a CGI would be cleaner and work for many more browsers. Something like:
- Code: Select all
#!/usr/bin/perl
if ($ENV{'HTTP_USER_AGENT'} =~ /MSIE/) {
print "Location: http://your.site.com/msie.version.html\r\n\r\n";
} elsif ($ENV{'HTTP_USER_AGENT'} =~ /^Mozilla/) {
print "Location: http://your.site.com/mozilla.version.html\r\n\r\n";
} else {
print "Location: http://your.site.com/some.other.browser.html\r\n\r\n";
}
Naturally, add an HTTP response code header if this is NPH or running under altered CGI environments like HTTPi.