Hello. Looking to create a script that:
Detects mobile browser (or mobile phone)
then produces dialogue (confirm/cancel)box to action re direct to another URL
Printable View
Hello. Looking to create a script that:
Detects mobile browser (or mobile phone)
then produces dialogue (confirm/cancel)box to action re direct to another URL
this looks promising http://localstreamer.posterous.com/j...detect-all-mob
Code:<script type="text/javascript">// <![CDATA[
    var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
    if (mobile) {
        document.location = "http://www.yoursite.com/mobile.html";
    }
// ]]></script>
This looks great. Haven't tested it yet. I'm curios as to where the confirm box code is stored ?
I'll update this as resolved ASAP.
I believe this will suffice. - Just a note, most sites seem to do it automatically these days and provide a link to the main site on the mobile site. Just a thought
Code:<script type="text/javascript">// <![CDATA[
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
var answer = confirm("Would you like to view the mobile version of the site?")
if (answer){
document.location = "http://www.yoursite.com/mobile.html";
}
}
// ]]></script>
Assuming you offer a mobile site for small screen sizes:
Code:<script type="text/javascript"> /* Put on mobile site. Auto-diverts to main if screen width > 500 */
if( screen.width > 500 && !/(\?|\&(amp;)*)useMobile=yes(&|$)/.test( location.search ) )
location.href = 'myMainSite.htm';
</script>
<!-- On main site -->
<a href='myMobileSite.htm?useMobile=yes'>Use Mobile-Optimised Site</a>