2 JS scripts determine whether the mobile browser will jump to the WAP mobile website

888u

Last update at :2024-06-20,Edit by888u

With the popularity of mobile devices, corporate online promotions can no longer be limited to the PC side, but need to make achievements on the mobile side as well. For company websites, they used to be made on the PC side. Of course, mobile terminals such as mobile phones can also be accessed, but the user experience is definitely not as convenient as the fully suitable mobile terminal. After we build a WAP mobile website for our website, if a user accesses our corporate top-level domain name website through a mobile phone, we will jump to the specially designed WAP website.

Here Snail has sorted out two JS scripts that he is currently using. Because friends have been asking me for them before, I share them here.

The first type: direct JS script

The second, slightly longer, quote

function uaredirect(murl){try {if(document.getElementById(\\”bdmark\\”) != null){return;}var urlhash = window.location.hash;if (!urlhash.match(\ \”fromapp\\”)){if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) {location.replace(murl);}}} catch(err) {}}

The above script is saved to the mobile.js file, and then the following two JS call files are referenced on the page that needs to be called.

Both methods can be used. I tested it on Android and IPHONE.

Recommended site searches: Which Hong Kong server is fast, registered domain name query, domain name registration query, registration number query, American European cloud server, Yangzhou dual-line server, ip online agent, online store virtual host, same ip website query, United States Host comments,

2 JS scripts determine whether the mobile browser will jump to the WAP mobile website

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码