deepa ashwi

deepa ashwi

  • NA
  • 109
  • 602.9k

javascript to detect screen width for a mobile device

Oct 18 2013 7:18 AM
Hi,
  i am doing mobile version for my website .what i am doing here is when page is loaded , in my home.html(desktop version) i am writing javascript here,i am detecting with mobile names but what i need  is i want to detect to check with the  width of mobile device(e.g.,800px) rather with mobile names.how to do?



<script>

var ua = navigator.userAgent;

 if ((ua.match(/iPhone/i)) || (ua.match(/Android/i))) {

 location.replace("mhome.html");

 }

</script>


Answers (1)