FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Mar 10, 2012, 8:09 AM
14 Posts
topic has been resolvedResolved

Detecting if you use Safari or not

  • Category: Other
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 5
If you only want to change the Custom Control if you surf to a page with Safari, how do you proceed when you do that?
 
Regards
Willy
Mar 10, 2012, 8:58 AM
272 Posts
Re: Detecting if you use Safari or not
 Hi,
 
you can detect Safari with SSJS:
 
context.getUserAgent().isSafari()
 
This could be added to the rendered properties of your custom controls.
 
Hope this helps 
Sven 
 
Mar 11, 2012, 4:17 AM
14 Posts
Re: Detecting if you use Safari or not
Have tried that but then hides it even for google chrome
Mar 11, 2012, 5:28 AM
272 Posts
Re: Detecting if you use Safari or not
This behaviour is caused because both browsers are using the webkit engine and the getUserAgent() method only checks the HTTP Header sent by the browser if there is a specific string inside.
 
You have to check for Safari *only* by checking if it is not Chrome too:
 
context.getUserAgent().isSafari() && !( context.getUserAgent().isChrome() )
 
Sven
 
Mar 11, 2012, 9:13 PM
90 Posts
Re: Detecting if you use Safari or not
If you ever need to narrow down *what* they are using Safari on, here's some code for iPod Touch, iPad and iPhone (and that can be reversed to eliminate those possibilities)
 
http://www.htmlgoodies.com/beyond/webmaster/toolbox/article.php/3888106/How-Can-I-Detect-the-iPhone--iPads-User-Agent.htm
Mar 12, 2012, 4:15 AM
14 Posts
Re: Detecting if you use Safari or not
thanks for the help, really appreciate it
 
Regards
Willy

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.