Mobile Geräte erkennen mit JavaScript

Oftmals müssen Webseiten an ein spezifisches Endgerät angepasst werden. Dazu muss man wissen, mit welchem Gerät man es überhaupt zu tun hat. Dabei kann einem die Navigator userAgent Property behilflich sein.
Mobile Geräte erkennen mit JavaScript weiterlesen

Hide address bar on iPhone, iPad and Android with JavaScript

If you want to constantly hide the address bar on mobile devices like iPhone, iPad and Android smartphones/tablets, then you have to scroll the window even if the device is turned:

1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">
function hideAddressBar(){
  window.scrollTo(0, 1);
}
 
window.onload = hideAddressBar;
window.onscroll = hideAddressBar;
window.onresize = hideAddressBar;
window.onorientationchange = hideAddressBar;
</script>

Short version:

<script>
window.onload = window.onscroll = window.onresize = window.onorientationchange = function(){
  window.scrollTo(0, 1);
};
</script>