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('mobile'); window.addEventListener('load', function(event) { setTimeout(function () { hab('#sup-post-2'); hab('#gd1-inner'); }, 1000); }); </script>
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!