PDA

View Full Version : iPhone/Android Redirect to Mobile App


SteveLV702
05-01-2011, 05:04 PM
I have a iPhone and Android App in the App Store/Market and I have setup so when someone goes to my site via the iPhone or Android browser they get an alert that there is a Mobile App and then they get redirected to the app in the appropriate store...

just I have the code in 'header" and "headerinclude" template and when go to my site via phone browser it pretty much loads the entire site before the alert appears so need to know a better location for the code so loads quickly....

here is copy of the code I have


header
------------------
<body onload="iPhoneAlert( );">


headerinclude
------------------
<script type="text/javascript">
function iPhoneAlert( )
{
if ( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) )
{
var qes+ += confirm( "This forum has an iPhone app! Click OK to learn more about Digital Mayhem Mobile for iPhone." );
if ( qes )
window.location+ += "http://dmlinks.us/DMMobile-iOS";
}
else if ( navigator.userAgent.match(/Android/i) )
{
var qes+ += confirm( "This forum has an Android app! Click OK to learn more about Digital Mayhem Mobile for Android." );
if ( qes )
window.location+ += "market://details?id=com.vbulletin.build_113";
}
}
</script>