当前位置:网站首页>phpcms v9手机访问电脑站一对一跳转对应手机站页面插件
phpcms v9手机访问电脑站一对一跳转对应手机站页面插件
2022-06-26 08:38:00 【cms小程序插件【官方】】
网上有很多种跳转代码,有的通过控制器跳转不同的模板,有的是通过js跳转,但是都有一个特点就是无法实现,pc和wap页面的一对一跳转,这就很坑了,一直想解决这个问题,直到今天才想到一个好方法:
第一:首先在公共头部引入一个本站api文件:jumpwap.php
- <script language="JavaScript" src="{APP_PATH}api.php?op=jumpwap&id={$id}&catid={$catid}&page={$page}"></script>
参数分析:
id表示文章的id,列表页和首页为空
catid 栏目id,为空说明是首页
page分页,如果pc站分页和手机站分页不一致,建议去掉该参数,否则可能造成分页错误
第二部分:在头部head里边添加js代码,最好在第一步代码后边,
- <script type="text/javascript">
- var userAgentInfo = navigator.userAgent;
- var wapurl = $('meta[name="wapurl"]').attr("content");
- if (userAgentInfo.indexOf("Android") > 0 || userAgentInfo.indexOf("iPhone") > 0 || userAgentInfo.indexOf("SymbianOS") > 0 || userAgentInfo.indexOf("Windows Phone") > 0 || userAgentInfo.indexOf("iPod") > 0 || userAgentInfo.indexOf("iPad") > 0)
- {
- if(wapurl){
- window.location.href = wapurl;
- }else{
- window.location.href = "http://m.pweb123.com/index.php";
- }
- }
- </script>
第三步:开发jumpwap.php文件
部分代码:
这样就可以实现手机电脑网站页面一对一跳转了,无论有没有静态化都可以实现跳转,
为了拒绝伸手党,代码暂时不开源,如果你觉得对你有用,你可以对我打赏,多少无所谓,尊重劳动成果,码农不易,多多理解!
边栏推荐
- In automated testing, there are three commonly used waiting methods: sleep, implicitly\wait, and expected\u conditions
- Pandas vs. SQL 1_ nanyangjx
- Addition of attention function in yolov5
- Clion installation + MinGW configuration + opencv installation
- Fourier transform of image
- Google Chrome collection
- KNN resolution
- Simulation of parallel structure using webots
- Backward usage
- Code de mise en œuvre de l'intercepteur et du filtre
猜你喜欢

Convex optimization of quadruped

框架跳转导致定位失败的解决方法

Slider verification - personal test (JD)

Principle of playing card image segmentation

Selenium builds cookies pool to bypass authentication and anti crawl login

力扣399【除法求值】【并查集】

Relation extraction model -- spit model

Mongodb分片环境搭建和验证(redis期末大作业)

pgsql_ UDF01_ jx

20220623 Adobe Illustrator入门
随机推荐
[resolved]setonnavigationitemselectedlistener() deprecated
Fast construction of neural network
Object extraction_ nanyangjx
Ultrasonic image segmentation
Relationship extraction -- casrel
自动化测试中,三种常用的等待方式,强制式(sleep) 、 隐式 ( implicitly_wait ) 、显式(expected_conditions)
Computer mall based on SSM
Whale conference provides digital upgrade scheme for the event site
上下架和橱窗推荐如何设置,优化过程需要注意的地方
Relationship extraction --tplinker
Implementation of ffmpeg audio and video player
Section IV HQL execution process
隐藏式列表菜单以及窗口转换在Selenium 中的应用
nn. Modulelist and nn Sequential
Analysis of Yolo series principle
基于SSM的电脑商城
Corn image segmentation count_ nanyangjx
Recovering the system with Clonezilla USB disk
唯品会工作实践 : Json的deserialization应用
Using MySQL and Qt5 to develop takeout management system (I): environment configuration