Pages

Friday, December 14, 2012

Javascript code to redirect mobile phone users

Views

I have a javascript code to redirect mobile phone users. Could you please check the code, I've picked it up from the net, total newb and I'd value your input regarding the quality of the script... Does it cover all types of mobile phones?


<script type="text/javascript">
function RedirectSmartphone(url){
    if (url && url.length > 0 && IsSmartphone())
    window.location = url;
}
function IsSmartphone(){
    if (DetectUagent("android")) return true;
    else if (DetectUagent("iphone")) return true;
    else if (DetectUagent("ipod")) return true;
    else if (DetectUagent("symbian")) return true;
    return false;
}
function DetectUagent(name){
    var uagent = navigator.userAgent.toLowerCase();
    if (uagent.search(name) > -1)
    return true;
    else
    return false;
}
RedirectSmartphone("http://mobile.version.com");
</script>
   
Ty very much!   

0 comments:

Post a Comment

 

Web Design Company karimnagar, Web Designing warangal, Logo Design Company nizamabad, Indian Website Design Company, maddysoft.co.in