home page Site building tutorial web front end text

Web detection access device mobile terminal or other handheld devices

Judge the device accessing the website. If it is a mobile terminal browsing, jump to the wap mobile terminal website Method 1:<script type="text/javascript">var mobileUrl="wap. umhtml. com"; if (/iphone|nokia|sony|ericsson|mot|samsung...

Determine the device accessing the website, if it is Mobile terminal Browse Jump Go to wap mobile website

 Web detection and access device mobile terminal or other handheld device client response js judgment handheld device mobile terminal Figure 1

Method 1:

 <script type="text/javascript">     var mobileUrl = "wap.um html .com";      if (/iphone|nokia|sony|eri css on|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|android|iPod/i.test(navigator.userAgent.toLowerCase())) {      if (mobileUrl)      {          document.location.href = mobileUrl;              }   } </script>

Method 2:

 <script type=”text/javascript”> if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { window.location = “wap.umhtml.com”; //It can be changed to http address } </script>


Method 3 (using the Device.js library):

Download address: https:// GitHub .com/matthewhudson/device.js

STEP 1: Import JS file

 <script src=”device.min.js”></script>

STEP 2: Add judgment code

 <script type=”text/javascript”> if(device.mobile()){ window.location = “wap.umhtml.com”; //It can be changed to http address } </script>

There are many Device.js methods. If you want to judge a device, you should replace device. mobile() with the following code.

 Web detection and access device mobile terminal or other handheld device client response js judgment handheld device mobile terminal Figure 2

Reward
poster

This article is written by Beautiful theme Original or collected and released

Please indicate the address of this article for reprinting: https://www.umtheme.com/web/41.html

Related recommendations

 CSS cardioid winding rotation effect

CSS cardioid winding rotation effect

CSS heart-shaped winding and rotating effect is an interesting animation effect, which can bring romantic and dynamic atmosphere to web pages. This effect will rotate a heart-shaped pattern infinitely, and twist around a central point at the same time
web front end 2023.09.13 zero two thousand seven hundred and twenty-two
 Create css3 animation effects commonly used in h5

Create css3 animation effects commonly used in h5

Css3 provides many powerful special effects that can be used to achieve a variety of effects. Here are some common css3 effects that I summarize, which can be directly referenced if necessary: 1. Zoom in when levitating:. one {transition: All 0.4s&nb
web front end 2023.09.13 one two thousand six hundred and sixty-nine
Comment List
 yibin
Not bad
2017-11-10 19:55:20 reply
 umtheme
Reply
2017-11-10 19:29:46 reply
 umtheme
@umtheme Well done!
2017-11-10 19:30:20 reply
 yibin
2017-11-10 19:54:27 reply
 umtheme
@yibin Reply to you
2017-11-10 23:09:13 reply
 umtheme
2017-11-10 19:29:54 reply

Thank you for your support