I would like display the message "You are not using Chrome, CLICK HERE for download Chrome. But I don't want display message if the browser used is Safari. In practice I want especially convince people who use IE (too crappy) and FF (too heavy) or any others browser (except Safari because is not bad and because any other third party browser who could be installed on Apple OS will have bad performance) to use instead Chrome (ideal choice for my app for a best user experience).
I found a script who seem to be well adapted for make a reliable detection, but I don't know how to customize the code:
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
}
]
};
BrowserDetect.init();
Can somebody help? If needed I found the script here: