当前位置:网站首页>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文件
部分代码:
这样就可以实现手机电脑网站页面一对一跳转了,无论有没有静态化都可以实现跳转,
为了拒绝伸手党,代码暂时不开源,如果你觉得对你有用,你可以对我打赏,多少无所谓,尊重劳动成果,码农不易,多多理解!
边栏推荐
- nn. Modulelist and nn Sequential
- Yolov5进阶之四训练自己的数据集
- OpenGL display mat image
- Implementation of ffmpeg audio and video player
- Software engineering - personal assignment - question review and personal summary
- Structure diagram of target detection network
- Leetcode: array fast and slow pointer method
- SRv6----IS-IS扩展
- ImportError: ERROR: recursion is detected during loading of “cv2“ binary extensions. Check OpenCV in
- Addition of attention function in yolov5
猜你喜欢
随机推荐
Pandas vs. SQL 1_ nanyangjx
Software engineering - personal assignment - question review and personal summary
Convex optimization of quadruped
Degree of freedom analysis_ nanyangjx
爬虫 对 Get/Post 请求时遇到编码问题的解决方案
isinstance()函数用法
Fast construction of neural network
Koa_mySQL_Ts 的整合
Tensor
SQL learning experience (II): question brushing record
20220623 getting started with Adobe Illustrator
Reverse crawling verification code identification login (OCR character recognition)
Simulation of parallel structure using webots
远程工作的一些命令
20220623 Adobe Illustrator入门
Euler function: find the number of numbers less than or equal to N and coprime with n
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (I)
9. code generation
Parameter understanding of quad dataloader in yolov5
OpenGL display mat image








![[unity mirror] use of networkteam](/img/b8/93f55d11ea4ce2c86df01a9b03b7e7.png)
