Identifying Safari/webkit in HTML

N

Neil Gould

Anyone know of a reliable way to identify Safari via HTML headers? I know
how to hack CSS to provide Safari-specific style variants, but I'd like to
provide different content rather than styles.
 
N

Neil Gould

Doug said:
Nope. Any scripting language (VBScript, PHP, Perl, etc.) can provide
any
headers it damn pleases when establishing an HTTP connection --
there's
absolutely no way to tell the difference between a connection from a
Safari
browser, and a connection from a Visual Basic script that's
pretending to be a
Safari browser.
Yes, I know that one can spoof other browsers via scripts, but that is not
of concern to what I'm trying to accomplish.
Why on earth would you want to do that?
The immediate reason is to bypass the wrestling match between Apple and
Adobe over support of flash animations. But, it would also be handy to
redirect to a different CSS rather than hack one CSS into non-compliance.
 
D

Doug Miller

Anyone know of a reliable way to identify Safari via HTML headers?

Nope. Any scripting language (VBScript, PHP, Perl, etc.) can provide any
headers it damn pleases when establishing an HTTP connection -- there's
absolutely no way to tell the difference between a connection from a Safari
browser, and a connection from a Visual Basic script that's pretending to be a
Safari browser.
I know
how to hack CSS to provide Safari-specific style variants, but I'd like to
provide different content rather than styles.

Why on earth would you want to do that?
 
I

idle

Yes, I know that one can spoof other browsers via scripts, but that is not
of concern to what I'm trying to accomplish.

The immediate reason is to bypass the wrestling match between Apple and
Adobe over support of flash animations. But, it would also be handy to
redirect to a different CSS rather than hack one CSS into non-compliance.

http://net.tutsplus.com/tutorials/h...ck-tip-html-5-video-with-a-fallback-to-flash/

http://flarevideo.com/
http://www.longtailvideo.com/players/
 
C

cwdjrxyz

Anyone know of a reliable way to identify Safari via HTML headers? I know
how to hack CSS to provide Safari-specific style variants, but I'd like to
provide different content rather than styles.

A few years ago I needed to identify Safari to avoid a certain media
bug it then had, now long gone. A php method seemed to work well then
for my problem. Since this php code is free to use and distribute, I
made a text copy of it at http://www.cwdjr.net/flash2/browdet.txt .
The code has extensive notes by the author of it. I have not had to
use this code for quite a while, so I do not know if it will work well
for the most recent Safaris.
 
N

Neil Gould

cwdjrxyz said:
A few years ago I needed to identify Safari to avoid a certain media
bug it then had, now long gone. A php method seemed to work well then
for my problem. Since this php code is free to use and distribute, I
made a text copy of it at http://www.cwdjr.net/flash2/browdet.txt .
The code has extensive notes by the author of it. I have not had to
use this code for quite a while, so I do not know if it will work well
for the most recent Safaris.
..
Thanks. I was hoping this could be done in HTML to avoid having to pass
variables to the page, but this may be the next best thing.
 
C

cwdjrxyz

.
Thanks. I was hoping this could be done in HTML to avoid having to pass
variables to the page, but this may be the next best thing.

I have a test page at http://www.cwdjr.net/flash2/DetectSafari.php and
you will need to see http://www.cwdjr.net/flash2/DetectSafari.txt to
view the php code. I only have the most recent Safari browser for
Windows. On it, Safari still seems to be detected correctly. Also, the
xhtml 1.1 page is converted to html 4.01 strict only if Safari is
detected. Several versions of Safari back, some media would not show
on Safari if you used true xhtml 1.1 served properly, even though
header exchange did show that Safari would accept application/xhtml
+xml. Thus the page was forced to be rewritten as html 4.01 strict if
Safari was detected to force the media to show. This bug was corrected
several versions of Safari ago.
 
C

cwdjrxyz

I have a test page athttp://www.cwdjr.net/flash2/DetectSafari.phpand
you will need to seehttp://www.cwdjr.net/flash2/DetectSafari.txtto
view the php code. I only have the most recent Safari browser for
Windows. On it, Safari still seems to be detected correctly. Also, the
xhtml 1.1 page is converted to html 4.01 strict only if Safari is
detected. Several versions of Safari back, some media would not show
on Safari if you used true xhtml 1.1 served properly, even though
header exchange did show that Safari would accept application/xhtml
+xml. Thus the page was forced to be rewritten as html 4.01 strict if
Safari was detected to force the media to show. This bug was corrected
several versions of Safari ago.

It turns out that the browdet.php file results in false detection of
Chrome and Flock browsers as Safari. These browsers likely were not
used or different when this 2007 lite version of the detection php
code was released. The same author has a complete version that has
been greatly updated with a copyright date of Dec. 2010 . If you use
this newer complete version of the detection php, Chrome and Flock are
not mistaken for Safari. The new detection code is at
http://www.cwdjr.net/flash2/browdetcomp.txt . This is used as an
include in the example page I gave at http://www.cwdjr.net/flash2/DetectSafari.php
with a text version at http://www.cwdjr.net/flash2/DetectSafari.txt.
Thank goodness, the complete detection script can be used as an
include, because it is extremely long and is likely to give you a
headache if you study it in detail :). Browser version identification
is very tricky, and it must be checked often as new versions of
browsers are released. It is best to avoid it, when posible. From the
complexity of the complete detection version given, it is apparent
that development of browser detection code is best left to specialists
who have much time available.
 
N

Neil Gould

cwdjrxyz said:
It turns out that the browdet.php file results in false detection of
Chrome and Flock browsers as Safari. These browsers likely were not
used or different when this 2007 lite version of the detection php
code was released. The same author has a complete version that has
been greatly updated with a copyright date of Dec. 2010 . If you use
this newer complete version of the detection php, Chrome and Flock are
not mistaken for Safari. The new detection code is at
http://www.cwdjr.net/flash2/browdetcomp.txt . This is used as an
include in the example page I gave at
http://www.cwdjr.net/flash2/DetectSafari.php
with a text version at http://www.cwdjr.net/flash2/DetectSafari.txt.
Thank goodness, the complete detection script can be used as an
include, because it is extremely long and is likely to give you a
headache if you study it in detail :). Browser version identification
is very tricky, and it must be checked often as new versions of
browsers are released. It is best to avoid it, when posible. From the
complexity of the complete detection version given, it is apparent
that development of browser detection code is best left to specialists
who have much time available.
I fully agree with your assessment, which is why I'd prefer to avoid it.

Thanks again for your help on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top