Created
April 27, 2011 13:51
-
-
Save stevef/944280 to your computer and use it in GitHub Desktop.
redirect to app store if registered protocol is not available
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var iDeviceRedirect = function( url, appPath ) | |
{ | |
if ( url ) | |
{ | |
window.mobileDetected = true; | |
// for iDevice, we do redirect on document load. | |
// After redirect, if our script is still running, | |
// that means that the redirect failed. We then | |
// show a dialog box asking to download the app | |
window.onload = function() | |
{ | |
var noAppMessage = 'You do not seem to have Insider installed, do you want to go download it now?'; | |
MobileDetect.redirect( url ); | |
setTimeout( | |
function() | |
{ | |
if ( confirm( noAppMessage ) ) | |
MobileDetect.redirect( appPath ); | |
}, | |
300 | |
); | |
} | |
showMobileAppDownload( appPath ); | |
} | |
} | |
// here's MobileDetect.redirect, no brain surgery required | |
var redirect = function( url ) | |
{ | |
try | |
{ | |
location.href = url; | |
} | |
catch(error) | |
{ | |
return true; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment