jQuery Mobile"加载页面错误"

Sri*_*uri 5 jquery html5 jquery-mobile

我正在使用Jquery1.8.2和Jquery-mobile 1.1

当我点击退出按钮时,我必须转到主页.我能够获得主页但在返回主页之前得到了"错误加载页面"消息.

的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>
Run Code Online (Sandbox Code Playgroud)

test.js

$(document).ready(function(){   
$("#logoutbtn").click(function () {     
    document.location.href = "Home.html";
});
});
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题.

and*_*eer 7

您应该使用jquery移动特定方法.

$.mobile.changePage("Home.html");
Run Code Online (Sandbox Code Playgroud)

请参阅document-location-href-location-vs-mobile-changepagelocation


Sri*_*uri 2

谢谢迪帕克斯

代替

document.location.href = "/Home.html";
Run Code Online (Sandbox Code Playgroud)

我已将其修改如下

document.location.href = "./Home.html";
Run Code Online (Sandbox Code Playgroud)

它工作正常,能够返回主页,没有任何错误。