I gave this a try using this code
{exp:browser_sniff}
{if browser_name=="saf" AND browser_version<3}
Some code
{/if}
{/exp:browser_sniff}
and it didn’t work for me. I used a lower level safari browser 1.3 and 2 and neither was detected as being a lesser version of 3 (or 3.1). In a separate test it detected both browsers as being safari though.
Did you check what you get with the following?
{exp:browser_sniff}
browser name: {browser_name}
browser version: {browser_version}
{/exp:browser_sniff}
Also you might want to try what $_SERVER[“HTTP_USER_AGENT”] in general is showing as a difference between the browser versions. Here’s a test page for this: http://sqa.fyicenter.com/Online_Test_Tools/__Show_Web_Browser_Information.php
Thanks for the suggestions.
I’m not receiving any info back in the template using these plugin tags below with any of the safari browsers:
{exp:browser_sniff}
browser name: {browser_name}
browser version: {browser_version}
{/exp:browser_sniff}
I went to that browser detection page .(JavaScript must be enabled to view this email address) with Safari 3.1 browser and a 1.3.2 browser. I took screen shots of the version info detected and attached a combined image of both below (one on top is the 3.1 version).
Basically, it looks like it detects a version number for the 3.1 browser but not for the earlier ones. It does provide other numbers for the browsers (525.13 & 312.6) but I wasn’t having any luck trying to use the conditional with those.
I had a look at the code at how the needed functionality can be added.
So I added three lines of code to accomplish what we want here. Now you get return values for {browser_name} and {browser_version}. This way you can check what gets detected. I’ve attached a new version to this post and I’ve updated the plugin documentation.
I’m no programmer and I don’t know much about PHP, I just browsed the PHP and EE developer docs for a while to figure out how I could return the conditionals evaluation and swap the template variables content. Looks like it turned out well. If someone feels I missed something please let me know.
The following should now work as expected:
{exp:browser_sniff}
browser name: {browser_name}
browser version: {browser_version}
{/exp:browser_sniff}
Cheers, Timon
Let me know how it works for you. The version returned is the Safari build version not the WebKit version as you can see. You might find this handy for defining the right number range Safari and WebKit Version Information
Hi,
I have updated Browser Sniff plugin. You can download version 1.1.9 using the link in the first post in this thred.
The code of the new version incorporates additions of Timon (eexperience) which allow for {browser_name} and {browser_version} variables to be used both inside and outside conditionals.
Many thanks, Timon, for your help!
Hi,
I have released version 1.2 of Browser Sniff plugin.
In this version a serious bug - PHP error message saying that browser_version variable is undefined being displayed when outputted browser name is “other” - was fixed.
Most importantly this bug prevented using online validation services such as W3C validator. After analyzing user agent string of a validator plugin outputted browser name “other”, then because of the bug a PHP error message was being printed on the top of the web page, and this automatically resulted into markup of the web page being invalid.
Everyone who uses Browser Sniff plugin is recommended to upgrade.
The workaround in the mean time it to target the CSS3 selector :nth-child that no other browser supports, save Safari 3, which does.
/*Safari 3.x webkit-min hack can effect Opera 9.x too*/
@media screen and (-webkit-min-device-pixel-ratio:0) {
/* :nth-child target only Konqueror 3.x (Safari 3.x) hat tip to http://tanreisoftware.com/blog/?p=39#konq*/
html:not(:nth-child(1)) add selector here{
padding: blah, blah...
}
}
Hi grantmx,
I just noticed that since the release of FF3 when you do a specific sniff for saf (safari), it picks up FireFox 3 too.
To test it I tried this code with Firefox 3.0.1 on Vista:
{exp:browser_sniff}
{if browser_name=="saf"}
Browser name: {browser_name}
Browser version: {browser_version}
{/if}
{/exp:browser_sniff}
and it worked as expected, that is there was no output.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.