How to detect mobile device and get user agent info send and save that information to database on server, only once?

后端 未结 3 1720
不思量自难忘°
不思量自难忘° 2020-12-13 22:38

Is there any script to check user agent then send and save that information to database on server?

I\'m making mobile website with 2 versions like m.facebook.com

相关标签:
3条回答
  • 2020-12-13 22:58

    As far as only detecting and saving the data once, you can set a cookie to record the fact that you've already done the detection. Then the next time a page is loaded, check to see if the cookie exists -- if it doesn't, then call your detection function and record to the database. If you do find the cookie, then you know you've already collected the data and you can skip doing it again.

    http://www.quirksmode.org/js/cookies.html

    0 讨论(0)
  • 2020-12-13 23:01

    see below link, this will perfectly suitable for your need

    http://detectmobilebrowser.com

    below is one more script :

    http://detectmobilebrowsers.mobi

    0 讨论(0)
  • 2020-12-13 23:06

    You might want to look into jQuery's take on this, since it's interesting.

    In addition to detecting the browser, they detect browser features:

    http://api.jquery.com/jQuery.browser/

    http://api.jquery.com/jQuery.support/

    Also, keep in mind that some mobile users don't want to be redirected to the mobile-optimized device. I, for one, positively hate it when a site detects my iPad as a mobile device and sends me (without any possibility to override it) to a sloppy mobile site that I wouldn't even want to browse with an iPhone.

    iOS and Android devices, in general, will happily work with the standard site if it's coded properly. And other mobile phones are quickly dying.

    0 讨论(0)
提交回复
热议问题