# Detecting Safari



## rhale1 (Feb 26, 2003)

How would I go about checking in my HTML code if the user is using Safari? Can I do this?

TIA,
Ryan


----------



## Giaguara (Feb 26, 2003)

Yes you can do that. This is an example of how Apple had it implemented in their page some time ago. 


```
<SCRIPT LANGUAGE = "JavaScript">
            var SafariMessage = "<IMG SRC=\"/home/images/2003/01/safarititle01202003.gif\" WIDTH=\"670\" HEIGHT=\"80\" ALT=\"WELCOME SAFARI USERS. The new PowerBooks.\">"
            var NoSafariMessage = "<IMG SRC=\"/home/images/2003/01/powerbooktitle01202003.gif\" WIDTH=\"670\" HEIGHT=\"80\" ALT=\"The new PowerBooks.\">"
            
            if (navigator.userAgent.indexOf('Safari') != -1) {
                document.write(SafariMessage);
            } else {
                document.write(NoSafariMessage);
            }
            </SCRIPT>
```


----------



## ksv (Mar 8, 2003)

> _Originally posted by Giaguara _
> *Yes you can do that. This is an example of how Apple had it implemented in their page some time ago.
> 
> 
> ...



There's something familiar about that code


----------

