Home > Web Front-end > JS Tutorial > Introduction to the method of determining whether it is a mobile page using js

Introduction to the method of determining whether it is a mobile page using js

高洛峰
Release: 2017-03-19 09:55:59
Original
1470 people have browsed it

This article mainly introduces the js method to determine whether it is a mobile page. It has a very good reference value. Let’s take a look at it with the editor.

Without further ado, please look at the code:

<script>
if (/mobile/i.test(navigator.userAgent) || /android/i.test(navigator.userAgent)) document.body.classList.add(&#39;mobile&#39;);
window.addEventListener(&#39;load&#39;, function(event) {
 setTimeout(function () {
  hab(&#39;#sup-post-2&#39;);
  hab(&#39;#gd1-inner&#39;);
 }, 1000);
});
</script>
Copy after login


The above is the detailed content of Introduction to the method of determining whether it is a mobile page using js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
js
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template