Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by mike99c
at 2024-02-17 06:47:17
Point:500 Replies:3 POST_ID:828887USER_ID:10
Topic:
jQuery;;Web Browsers
I would like to know the best way to detect if a browser is specifically Safari using jQuery.
I am aware that webkit is shared by Chrome and Safari but I am specifically interested to know if the browser is Safari and nothing else.
I am aware that webkit is shared by Chrome and Safari but I am specifically interested to know if the browser is Safari and nothing else.
Expert: duncanb7 replied at 2024-02-17 08:31:17
Thanks for your pt, there is a lot of solution in google search
for Jquery browser detection but that might NOT be
consistent and that some is depended on the jquery plugin version.
You can simplify those javascript code for your need that is not depend on
javascript version
Have a nice day
Duncan
for Jquery browser detection but that might NOT be
consistent and that some is depended on the jquery plugin version.
You can simplify those javascript code for your need that is not depend on
javascript version
Have a nice day
Duncan
Assisted Solution
Expert: duncanb7 replied at 2024-02-17 08:06:51
250 points EXCELLENT
Dear mike99c,
You can use the following javascript code to test Safari browser or not
I put the document.write in if statement for Safari browser detection only
and display it into body tag.
And if it is not Safari browser, it will keep the message of "It is NOT Safari Browser" in body tag.
The document.write you can put in other if statement for other browser you want to test
Hope I understand your question completely, if not please pt it out,
The code is Not fully tested
Duncan
You can use the following javascript code to test Safari browser or not
I put the document.write in if statement for Safari browser detection only
and display it into body tag.
And if it is not Safari browser, it will keep the message of "It is NOT Safari Browser" in body tag.
The document.write you can put in other if statement for other browser you want to test
Hope I understand your question completely, if not please pt it out,
The code is Not fully tested
Duncan
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "/WEB/INF/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=UTF-8"/> <meta http-equiv="CACHE-CONTROL" content="NO-STORE"/> <meta http-equiv="EXPIRES" content="-1"/> <title>Safari Browser Test</title> <script type="text/javascript"> function init(){var nVer = navigator.appVersion;var nAgt = navigator.userAgent;var browserName = navigator.appName;var fullVersion = ''+parseFloat(navigator.appVersion);var majorVersion = parseInt(navigator.appVersion,10);var nameOffset,verOffset,ix;// In Opera, the true version is after "Opera" or after "Version"if ((verOffset=nAgt.indexOf("Opera"))!=-1) { browserName = "Opera"; fullVersion = nAgt.substring(verOffset+6); if ((verOffset=nAgt.indexOf("Version"))!=-1) fullVersion = nAgt.substring(verOffset+8);}// In MSIE, the true version is after "MSIE" in userAgentelse if ((verOffset=nAgt.indexOf("MSIE"))!=-1) { browserName = "Microsoft Internet Explorer"; fullVersion = nAgt.substring(verOffset+5);}// In Chrome, the true version is after "Chrome"else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) { browserName = "Chrome"; fullVersion = nAgt.substring(verOffset+7);}// In Safari, the true version is after "Safari" or after "Version"else if ((verOffset=nAgt.indexOf("Safari"))!=-1) { browserName = "Safari"; fullVersion = nAgt.substring(verOffset+7); if ((verOffset=nAgt.indexOf("Version"))!=-1) fullVersion = nAgt.substring(verOffset+8); txt ="<p id='pd0' style='color:blue'> It is Safarai Browser, Browser name ="+browserName+'</p>'; document.write(txt);}}</script></head><body onload="init();">It is NOT Safari Browser</body></html> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:
Accepted Solution
Expert: leakim971 replied at 2024-02-17 07:05:41
250 points EXCELLENT
var isSafari = navigator.vendor.indexOf("Apple")==0 && /sSafari//.test(navigator.userAgent); // true or false 1: