【发布时间】:2014-02-09 16:54:18
【问题描述】:
我已搜索但未在论坛上找到我要查找的内容。我有一个标准的 HTML(不是 wordpress)网站。它在台式机和 ipad 上显示效果很好。我使用 jquery mobile 构建了一个非常缩小的移动版本,仅包含基本信息。
问题是,如何将移动文件仅提供给手机?我可以使用什么代码告诉手机使用 jquery 移动文件或 url 而不是普通的桌面文件?我还在网站的 jquery 移动版上添加了一个“查看完整网站”按钮。如果选择“查看完整站点”并且一旦选择不返回移动版本,我如何让手机显示完整站点?我在许多网站上都看到了这一点,但无法弄清楚。谢谢你的帮助!迈克
这是我在 mikeschaler.com 上的主要网站
// will allow to use sessions
session_start();
if(!isset($_SESSION['mobile_detect'])) {
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if ( $detect->isMobile() ) {
header('Location: mobile.mikeschaler.com');
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="/MESfavicon.ico" type="image/x-icon" />
<link rel="icon" href="/MESfavicon.ico" type="image/x-icon">
<title>Mike Schaler Media Services</title>
<style type="text/css"></style>
<link href="mikeSiteRedesign.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19130075-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
这是我尝试在 mobile.mikeschaler.com 上为移动用户提供服务的移动网站:
<!doctype html>
<html>
<head>
<title>Precison Garage Door</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="themes/Precision-Garage-Door.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="jquery.mobile.structure-1.4.0.min.css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="jquery.mobile-1.4.0.min.js"></script>
session_start();
$_SESSION['mobile_detect'] = 0;
header('Location: mikeschaler.com/index.html');
</head>
这就是你要找的吗?谢谢!
好的,我从 mobile.mikeschaler.com 网站上删除了代码。
我用“// 将允许使用会话会话开始...”代码创建了一个 php 文件。
在 mikeschaler.com 网站上,我在代码顶部插入了所有这些是否正确?迈克
完整的网站代码现在看起来像这样:
<?php
mobileRedirect.php
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
【问题讨论】:
-
您必须将 PHP 放入 并将文件另存为 .php。此外,从您的移动网站中停用 PHP 代码。我们将一步一步地做到这一点。
-
希望你看到我上面的回复。感谢您在这方面和我在一起!迈克
-
不忘记把代码放到中应该是对的
-
是的,我错过了。现在更改并重新上传了php文件。
-
但是我是否有权在整个站点上调用 php 重定向文件? 不确定执行 php 代码的语法。
标签: jquery html jquery-mobile mobile