2013-01-23 90 views
0

在我的jQuery手机(1.2版)网站,我有几个单独的页面(即每个页面有一个标题,内容和页脚)。问题是我无法链接页面。以下行不起作用。 <a href="anotherpage.html">Another Page</a>显示“Error loading page”。jQuery手机页面链接不工作

如果我将rel="external"添加到<a>元素,它将起作用。但是,它会通过Ajax关闭自动加载。但我想使用Ajax加载以及将页面分开。只是想知道是否有可能。

代码页1

<!DOCTYPE html> 
<html> 

<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Single page template</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"> </script> 
</head> 
<body> 
    <div data-role="page"> 
     <div data-role="header"> 
      <h1>Page 1</h1> 
     </div> 
     <div data-role="content"> 
      <a href="b.html"> click me</a> 
     </div> 
     <div data-role="footer"> 
      <h4>Footer content</h4> 
     </div> 
     </div> 
</body> 
</html> 

代码页2

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Single page template</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">  </script> 
</head> 
<body> 
    <div data-role="page"> 
     <div data-role="header"> 
      <h1>Page 2</h1> 
     </div> 
     <div data-role="content"> 
       page 2 content 
     </div> 
     <div data-role="footer"> 
      <h4>Footer content</h4> 
     </div> 
    </div> 
</body> 
</html> 
+1

你确定你的页面层次结构是正确的?或者,你可以尝试使用绝对网址 – adamdehaven

+0

向我们展示您的页面示例。这仅仅是不够的。 – Gajotres

+1

当您点击链接时,您的地址栏中的网址是您期望的网址?即它试图链接到一个子目录或其他东西,但你想要的文件是在根?想不到更合乎逻辑的解释... – Mike

回答

1

的问题是,你要加载从文件系统页面。 Chrome设置可以防止这种情况,假设存在安全风险。

通过Web服务器为您的页面提供服务。您可以在Windows XP Pro上使用IIS。

你可以用--allow-file-access-from-file命令行选项启动铬

0

我相信你应该给每个“数据角色=‘页面’和ID,如“第2页所以实际上这将是:

<div data-role="page" id="page"> <!--Home Page--> 
<div data-role="page" id="page2"> <!--2nd Page--> 
<div data-role="page" id="page3"> <!--3rd Page--> 

林不知道如果这是你在找什么在这种情况下,虽然...