Τετάρτη 23 Σεπτεμβρίου 2015

Mobile version web site transition - cell phone compatible sites

When you develop a web site, it is always a good practise to make a mobile version next to desktop version
Although smartphone browsers can project desktop web sites to users without problem, users may have difficulties browsing content because of  the minimized fonts.
To handle this problem developers can use some javascript control to show or hide div sections according to mobile or desktop version.
This simple code below can check if the website visitor is a smartphone or a desktop by just checking the device screen width and loading according related content.

 <script type="text/javascript">
  <!--

  if (screen.width <= 800) {
     document.getElementById("contactdiv").style.visibility="hidden";
     document.getElementById("contactMobile").style.position="relative";
     document.getElementById("contactdiv").style.position="absolute";
  }
  else {
     document.getElementById("contactMobile").style.visibility="hidden";   
  }

  //-->
</script>

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου