Actually my HTML website is not compatible with safari browser so i want to make all the safari users ask to use Google chrome for better user interface experience. Please can anyone provide me the code or set of code that i can use. I need a HTML code, NOT PHP. Need Help !!
Asked
Active
Viewed 44 times
-2
-
http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser – surya singh Oct 03 '15 at 12:16
-
Do you even know what JavaScript is? Since you think all provided code is PHP? – Daan Oct 03 '15 at 12:35
-
I'm voting to close this question as off-topic because SO does not write code for you so you should not ask such questions here. – Rob Oct 03 '15 at 15:08
2 Answers
1
if(navigator.userAgent.toLowerCase().indexOf('safari/') > -1) {
window.alert("Please use Google Chrome for a better user interface experience on this website.");
}
since you believe the above code is PHP, you could also use this:
if(Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) {
window.alert("Please use Google Chrome for a better user interface experience on this website.");
}

Daan
- 578
- 7
- 21
-
-
-
-
No problem! If this answer solved your problem, it would be greatly appreciated if you could mark it as the 'accepted answer'. This helps other users with the same problem to easily find the solution. – Daan Oct 03 '15 at 12:39
0
Try this...
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
if (isSafari == true){
alert('Please use Google chrome instead of Safari!');
}

Xahed Kamal
- 2,203
- 1
- 20
- 41
-
-
Huh! Its not PHP. Its javascript! You can put it in HTML file. In header or anywhere inside the body tag. – Xahed Kamal Oct 03 '15 at 12:33
-
-
-
You are welcome. You should mark the correct solution as the answer of our question! – Xahed Kamal Oct 03 '15 at 12:37