Thursday 15 March 2012

javascript - Show Mobile App dowload layer only in Mobiles and Tablets -


There are both our website and the original app (iOS and Android) for our company

Needs

I would like to show model mode of mobile and tablet in particular when user access to the device will show a message on the site that you can download our original. App

Problem

HTML, CSS & amp; Javascript code for these layers is affecting the weight of our page, by any means we can dynamically include code (HTML, CSS, and JavaScript) on mobile and the other; Tablet device

Thanks

Avinash Mduriuri

> UserAgent , according to me,

identifies your browser and provides some system details to the server hosting the websites you visit is.

A normal user will appear like this:

For Android phones, this will look like this:

Mozilla / 5.0 (Linux; U; Android 4.0.3; Ko -RR; LG-L 160L build / IML 74K) Apple WebKat / 534.30 (such as KHtml, GIKO) Version / 4.0 Mobile Safari / 534.30

This property can be accessed through the Navigator object in this way:

  navigator.usager   

See the demo here:

Now, to check that your browser is a mobile browser, we have established a system like this:

 < Code> var ua = navigator consumer agent; If (ua.indexOf ("Android") & gt; = 0) {// its Android phone var and androidview = parsflat (ua.slice (ua.indexOf ("Android" + 8)); If (androidversion! = 4.0 ) {// version of Android}} and if ((ua.indexOf ("iPhone")> = 0 || ua.indexOf ("iPad")> = 0) & amp; amp; Ua.indexOf ("CriOS") == -1) {// You are on iOS}   

Before you load anything, you have to keep it at the beginning of your document if you are loading If you want to stop everything from your page otherwise.

Note Krios Safari But the Chrome browser's user indicator is the reason why its iOS is included in the list.

No comments:

Post a Comment