Home >Backend Development >PHP Tutorial >javascript - tp framework. Develop website. There are PC version and mobile version. How to automatically identify the visitor's device and then enter different versions.

javascript - tp framework. Develop website. There are PC version and mobile version. How to automatically identify the visitor's device and then enter different versions.

WBOY
WBOYOriginal
2016-08-04 09:19:461079browse

TP framework develops websites with PC version and mobile version. How to automatically identify the visitor’s device and then enter different versions

There seems to be a very short Baidu code in my image that can achieve it, but now I can’t find it anymore. Please tell me the simplest method

Reply content:

TP framework develops websites with PC version and mobile version. How to automatically identify the visitor’s device and then enter different versions

There seems to be a very short Baidu code in my image that can achieve it, but now I can’t find it anymore. Please tell me the simplest method

<code>navigator.userAgent.match(/AppleWebKit.*Mobile.*/) </code>

<code>composer require mobiledetect/mobiledetectlib</code>

https://github.com/serbanghit...

Same answer useragent

mobile detect
is available on

github

You can also consider adaptive css framework like bootstrap

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn