Detecting the Safari Browser to load scripts

I needed to detect if Safari was being used as there were some issues with styling on a website I was working upon, only on Mac Safari though!!!

The following code is what I use to detect safari and load the relevant script:

<script type="text/javascript">

 		//you are using safari, or at least you CLAIM to be
		document.write('<link type="text/css" media="screen" rel="stylesheet" href="/css/safari.css" title="example" />');

Add in the tags and set the path to the correct css file you wish to load. Same concept can be used to load javascript files.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.