Skip to content

Files

Latest commit

 Cannot retrieve latest commit at this time.

History

History
22 lines (17 loc) · 944 Bytes

README.md

File metadata and controls

22 lines (17 loc) · 944 Bytes

iOSifyMaps.js

JavaScript script that changes Google Maps formatted links to iOS formatted links only on iOS devices.

What it does

  • Checks for an iOS Device via User Agent String (checks for iPhone, iPod and iPad)
  • Get's all anchor tags
  • Get's href of each anchor
  • Changes url from "maps.google.com" to "maps.apple.com"

How to Implements

  1. Place <script type="text/javascript" src="iOSifyMaps.js"></script> tag referring to js file right BEFORE </body> tag
  2. Use the following JavaScript after including this JS file: <script>document.getElementsByTagName('a').iOSifyMaps();</script>
  3. For more efficient JS, add an id to the targeted element and use getElementByID: <script>document.getElementByID('mapsLink').iOSifyMaps();</script>
  4. This can also be used with jQuery: <script>$('a[href*="maps.google.com"]').iOSifyMaps();</script>