In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use CMS to automatically identify PC and mobile". In daily operation, I believe many people have doubts about how to use CMS to automatically identify PC and mobile. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to use CMS to identify PC and mobile automatically". Next, please follow the editor to study!
The program supports automatic identification of PC and mobile domain names.
Computer domain name: www.xxxx.com mobile phone domain name: yd.xxxx.com
1. Set the computer domain name in the website configuration:
2. Enter the binding domain name interface to bind the domain name for the mobile phone.
When automatic recognition is checked, you can automatically judge and jump to the mobile interface, but the static page function cannot be enabled.
3. Enter the system for physical examination to see the results
If the prompt is green, it will be ok.
About static generation
When the static function is enabled, the php program will not be used to visit the website page, so the program cannot recognize the client by default, so we can only identify the client through js.
In principle, once the website uses static pages, it cannot automatically jump, because the static files cannot execute dynamic php scripts, so you need to manually add the identification jump code in the footer of the template:
Pc/***/footer.html
$(function () {var MobileUA = (function () {var ua = navigator.userAgent.toLowerCase ()) Var mua = {IOS: / ipod | iphone | ipad/.test (ua), / / iOS IPHONE: / iphone/.test (ua), / / iPhone IPAD: / ipad/.test (ua), / / iPad ANDROID: / android/.test (ua), / / Android Device WINDOWS: / windows/.test (ua) / / Windows Device TOUCH_DEVICE: ('ontouchstart' in window) | | / touch/.test (ua), / / Touch Device MOBILE: / mobile/.test (ua), / / Mobile Device (iPad) ANDROID_TABLET: false, / / Android Tablet WINDOWS_TABLET: false, / / Windows Tablet TABLET: false, / / Tablet (iPad, Android Windows) SMART_PHONE: false / / Smart Phone (iPhone, Android)} Mua.ANDROID_TABLET = mua.ANDROID & &! mua.MOBILE; mua.WINDOWS_TABLET = mua.WINDOWS & & / tablet/.test (ua); mua.TABLET = mua.IPAD | | mua.ANDROID_TABLET | | mua.WINDOWS_TABLET; mua.SMART_PHONE = mua.MOBILE & &! mua.TABLET If (ua.match (/ MicroMessenger/i) = = "micromessenger") {return true;} return mua;} (); / / SmartPhone if (MobileUA.SMART_PHONE) {/ / Mobile link address _ document.location.href ='{str_replace (SITE_URL, SITE_MURL, $my_web_url)}' })
Simplification (default js needs to be loaded)
1. Judge the jump to the mobile terminal in the pc interface.
$(function () {if (dr_is_mobile ()) {/ / Mobile Link address _ document.location.href ='{str_replace (SITE_URL, SITE_MURL, $my_web_url)}';}})
2. Judge and skip to pc on the mobile interface
(function () {if (! dr_is_mobile ()) {/ / PC end link address _ document.location.href ='{str_replace (SITE_MURL, SITE_URL, $my_web_url)}';}}). At this point, the study on "how to use CMS to automatically identify PC and mobile end" is over. I hope to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.