当前位置:网站首页>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文件
部分代码:
这样就可以实现手机电脑网站页面一对一跳转了,无论有没有静态化都可以实现跳转,
为了拒绝伸手党,代码暂时不开源,如果你觉得对你有用,你可以对我打赏,多少无所谓,尊重劳动成果,码农不易,多多理解!
边栏推荐
- OpenGL display mat image
- Whale conference one-stop intelligent conference system helps organizers realize digital conference management
- Structure diagram of target detection network
- Detailed explanation of traditional image segmentation methods
- 读书笔记:SQL 查询中的SQL*Plus 替换变量(DEFINE变量)和参数
- 框架跳转导致定位失败的解决方法
- Sqoop merge usage
- 直播回顾 | smardaten李鸿飞解读中国低/无代码行业研究报告:风向变了
- 基于SSM的毕业论文管理系统
- 【程序的编译和预处理】
猜你喜欢

Degree of freedom analysis_ nanyangjx

Recovering the system with Clonezilla USB disk

Using MySQL and Qt5 to develop takeout management system (I): environment configuration

Euler function: find the number of numbers less than or equal to N and coprime with n

Computer mall based on SSM

Yolov5进阶之二安装labelImg

Detailed explanation of traditional image segmentation methods

20220623 Adobe Illustrator入门

Relationship extraction -- casrel

Clion installation + MinGW configuration + opencv installation
随机推荐
1.20 study univariate linear regression
1.26 pytorch learning
攔截器與過濾器的實現代碼
How to correctly PIP install pyscipopt
Zlib static library compilation
远程工作的一些命令
Whale conference one-stop intelligent conference system helps organizers realize digital conference management
1.25 suggestions and design of machine learning
Exploration of webots and ROS joint simulation (I): software installation
Formula understanding in quadruped control
20220213 Cointegration
Fourier transform of image
Yolov5进阶之三训练环境
Code de mise en œuvre de l'intercepteur et du filtre
Drawing with MATLAB (2) -- color ring
Solution to the encoding problem encountered by the crawler when requesting get/post
深度学习论文阅读目标检测篇(七)中文版:YOLOv4《Optimal Speed and Accuracy of Object Detection》
isinstance()函数用法
KNN resolution
Detailed explanation of self attention & transformer