2012-10-16 163 views
5

我使用Jquery1.8.2和jQuery移動1.1jQuery Mobile的「加載頁面時出錯」

當我退出按鈕,我必須轉到主頁點擊。我能夠獲得主頁,但在返回主頁之前得到了「Error Loading Page」消息。

的test.html

<body> 
    <div data-role="page"> 
     <div data-role="header" data-theme="b" > 
      <h1> Success Page </h1> 
      <a data-role="button" id="logoutbtn" data-theme="b">Logout</a> 
     </div><!-- /header --> 
     <div data-role='content'>    
    </div> 
</div> 
</body> 

test.js

$(document).ready(function(){ 
$("#logoutbtn").click(function() {  
    document.location.href = "Home.html"; 
}); 
}); 

請幫我出這一點。

回答

3

感謝Dipaks

而不是

document.location.href = "/Home.html"; 

我已經修改了它像下面

document.location.href = "./Home.html"; 

它的做工精細,並且能夠回到主頁與出任何錯誤。

1

$.mobile.changePage("Home.html")我的電腦上沒有工作

而是$.mobile.changePage("#");的作品,它的隱藏error loading page消息。

1

我正在使用正確的版本和$ .mobile.changePage來改變一個頁面,它仍然失敗,同樣的錯誤。後來我意識到我在www/js/custom/handler/handler.js中的js文件中這樣做了。所以我使用相對於這個位置的路徑。

但是後來我意識到路徑必須相對於包含這個js的index.html。

這解決了我的問題。