2

How can I detect whether a user's browser supports iTunes Music Store (itms://) links?

If the browser supports it, I'd like to offer an itms:// link, so that it will open directly in iTunes. But for browsers that don't, I'd link to the object using https://itunes.apple.com.

I thought about offering itms:// only to Safari, but then realized that (at least on a Mac) Chrome also seems to support itms://. Also, detecting Safari seems a bit fragile. If possible I'd prefer to detect feature support rather than checking for a specific browser.

Community
  • 1
  • 1
George Armhold
  • 30,824
  • 50
  • 153
  • 232
  • See the answer here: http://stackoverflow.com/questions/3411875/how-to-detect-whether-a-protocol-is-supported-through-web-browser – Lawson Apr 17 '13 at 14:40
  • It also appears that this JS script might work: https://github.com/n0s/itunesdetect/blob/master/itunesdetect.js – Lawson Apr 17 '13 at 14:42

2 Answers2

0

I ended up using this script, which I founded immediately after posting, and which @Lawson also recommended.

Update: does not seem to work with IE on Windows 8. It fails to detect iTunes integration on that platform.

Community
  • 1
  • 1
George Armhold
  • 30,824
  • 50
  • 153
  • 232
0

If you know how to use "Inspect Element" on Google Chrome, etc, you would find the following javascript that uses a function called its.detect.iTunesDetected().

External scripts needed are from apple's website:
https://itunes.apple.com/htmlResources/EF6B/web-storefront-base.js
https://itunes.apple.com/htmlResources/EF6B/web-storefront-preview.js

<script>
        if(its.detect.itunesDetected()) alert("iTunes Installed");
</script>

Example Code.

Hope this helps.

Barnee
  • 3,212
  • 8
  • 41
  • 53
M B
  • 41
  • 5