2013-01-23 40 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--> 

林不知道如果這是你在找什麼在這種情況下,雖然...