Javascript mobile redirect issue -


hi has doing head in couple of days now, want redirect mobile websites checking site devices screen width of lower 699. using script redirection:

<script type="text/javascript"> <!-- if (screen.width <= 699) { window.location = "http://www.mywebsite.com.au/mobile/"; } //--> </script> 

the script working fine when checking site through firefox not working in dolphin browser..

it might cell phone have galaxy s2.

thanks in advance can me appreciate it!

new update :-----ok getting interesting. when reduce screen width 599, script works in dolpin browser.(screen.width <= 599) ---

i suggest using user agent detection

var ismobile = function() {    //console.log("navigator: " + navigator.useragent);    return /(iphone|ipod|ipad|android|blackberry|windows ce|palm|symbian)/i.test(navigator.useragent);  }; 

redirect this

if(ismobile()) {        window.location.href = "http://www.mywebsite.com.au/mobile/"; } 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -