I need a script that shows a different CPA offers when the Safari browser is used. Anyone have a script or method I could use?
(As some CPA offers do not show on Safari)
You can use PHP to pick up the visitors user_agent but apparently browser detection server side is a losing battle, since user_agents are often faked and many identify themselves as mozilla, etc. JS might be a better way to do it. Am a JS noob so can't help much but something like this might be useful?
[PHP]
var userAgent = navigator.userAgent.toLowerCase();
// Figure out what browser is being used.
var Browser = {
Version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
Chrome: /chrome/.test(userAgent),
Safari: /webkit/.test(userAgent),
Opera: /opera/.test(userAgent),
IE: /msie/.test(userAgent) && !/opera/.test(userAgent),
Mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent),
Check: function() { alert(userAgent); }
};
if (Browser.Chrome || Browser.Mozilla) {
// Do your stuff for Firefox and Chrome.
}
else if (Browser.IE) {
// Do something related to Internet Explorer.
}
else {
// The browser is Safari, Opera or some other.
}
[/PHP]
From http://stackoverflow.com/questions/1...-or-javascript
Stick this in your head tag:
<script type="text/javascript">
var url ="http://usethiscpaofferforsafari.com";
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { window.top.location=url; }
</script>
Thank you for the reply. I am going to test it out and see what happens 