Skip to content

Instantly share code, notes, and snippets.

Created July 8, 2014 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/a135239b522224121b3a to your computer and use it in GitHub Desktop.
Save anonymous/a135239b522224121b3a to your computer and use it in GitHub Desktop.
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var meta = document.getElementsByTagName('meta');
var apple_launch_elem;
for (var i=0;i < meta.length; i++) {
var elem = meta[i];
if (elem.getAttribute('name') === 'apple-itunes-app') {
apple_launch_elem = elem;
}
}
var launchurl = getParameterByName('launchurl')
if (apple_launch_elem) {
var tmp = apple_launch_elem.getAttribute('content');
apple_launch_elem.setAttribute('content', tmp + ', app-argument=' + decodeURIComponent(launchurl));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment