1
Answer

javascript to detect screen width for a mobile device

deepa ashwi

deepa ashwi

11y
1.3k
1
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)