允许通过jquery从移动网站切换到完整网站 [英] Allow switch from mobile site to full site with jquery

查看:110
本文介绍了允许通过jquery从移动网站切换到完整网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这里进行了一些挖掘,但仍然不确定如何实现此目的.这是场景:

I have done some digging out here and am still a little unsure how to accomplish this. Here is the scenario:

我有一个完整的HTML网站,该网站调用以下PHP代码:

I have a full HTML site that calls the following PHP code:

<?php
    require_once('inc/mobile_device_detect.php');
    mobile_device_detect(true,true,true,true,true,true,true,'mobile/',false);
?>
<!DOCTYPE html>
<html lang="en">
<head>blah blah</head>
etc...

mobile_device_detect.php是 http://detectmobilebrowsers.mobi/

The mobile_device_detect.php is a small library from http://detectmobilebrowsers.mobi/

因此,当我从手机访问整个站点时,重定向过程非常完美.接下来,在mobile/index.html上,我为那些希望查看完整网站的用户提供了以下重定向代码(我还要提到,该移动网站使用jquery-mobile):

So when I go to the full site from my mobile phone, the redirect happens perfectly. Next, on the mobile/index.html I have the following redirect code for those users that are wanting to see the full site (I should also mention that this mobile site uses jquery-mobile):

<a href="../index.html" data-ajax="false" rel="external"><img src="images/icons/world.png" width="32" height="32" alt="Full Site" class="ui-li-icon">Full Site</a>

当我单击此链接时,我会重新发送回移动页面.我知道发生这种情况是因为重新启动了重定向脚本.我已经通过使用桌面客户​​端访问移动网站进行了测试,并且重定向可以完美地进行.

When I click this link, I am resent back to the mobile page. I know this is happening because the redirect script is being fired again. I have tested this by visiting the mobile site with a desktop client and the redirect occurs perfectly.

有什么想法可以为希望查看完整网站"的移动用户提供解决方案吗?

Any ideas how I can remedy this for mobile users wanting to see the 'full site'?

推荐答案

您可以像在首页中的href="../index.html?full=true"一样,在您的href上附加一个查询参数,以确保不存在完整的参数.

You can append a query param on your href like href="../index.html?full=true" in your main page check that full param is not present.

<?php
    if (!isset($_GET['full'])) {
      require_once('inc/mobile_device_detect.php');
      mobile_device_detect(true,true,true,true,true,true,true,'mobile/',false);
    }
?>

这篇关于允许通过jquery从移动网站切换到完整网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆