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
1531 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
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
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template