2012-02-08 106 views
0

任何人都可以幫助我並告訴我爲什麼在此代碼中後退按鈕不起作用?我通過電子手機模擬器(http://www.electricplum.com/dlsim.html)在Chrome和Safari上嘗試了它。我用javascript($ .mobile.page.prototype.options.addBackBtn = true;)全局設置也嘗試了它。Jquery Mobile後退按鈕無法正常工作

後退按鈕已正確顯示,但當我點擊/點擊後退按鈕時,頁面會自行停止。在chrome中,我看到子頁面的Url顯示(#子頁面),在點擊後退按鈕後,url變回,但不是網站本身。

<!DOCTYPE html> 
<html> 
<head> 

    <meta name="viewport" content="width=device-width;initial-scale=1,user-scalable=0" /> 
    <title>Index.Mobile</title> 
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" /> 
    <link href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.css" rel="Stylesheet" type="text/css" /> 
    <script src="/Scripts/jquery-1.6.2.min.js" type="text/javascript"></script> 
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.js" type="text/javascript"></script> 

</head> 

<body> 

<h2>Index.Mobile</h2> 

<div data-role="page" id="home"> 

    <div data-role="header" data-position="fixed"> 

     <h1>Mobile Events</h1> 

    </div><!-- /header --> 

    <div data-role="content"> 
    <!---- BUTTON ----> 
      <div>some content</div> 
      <a href="#sub-page" data-role="button">Next Page</a> 
    </div><!-- /content --> 

    <div data-role="footer" data-position="fixed"> 
     <h4></h4> 
    </div><!-- /footer --> 

</div><!-- /page --> 

<div data-role="page" id="sub-page"" data-add-back-btn="true" data-back-btn-text="Back"> 
    <div data-role="header">   
     <h1>Page Header</h1>  
    </div> 

    <div data-role="content">  
     <p>This is the main content</p> 
    </div> 

    <div data-role="footer"> 
     <h4>Footer</h4> 
    </div>  
</div> 
</body> 

</html> 
+0

attribs粗心的腳本錯字'相對= 「樣式表」'本來應該有'rel = 「樣式」' – uday 2012-02-08 16:43:27

+0

請評價我的答案,如果它幫助。謝謝! – uday 2012-02-27 23:00:41

回答

0
<!DOCTYPE html> 
<html> 
<head> 

    <meta name="viewport" content="width=device-width;initial-scale=1,user-scalable=0" /> 
    <title>Index.Mobile</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> 

</head> 

<body> 

<h2>Index.Mobile</h2> 

<div data-role="page" id="home"> 

    <div data-role="header" data-position="fixed"> 

     <h1>Mobile Events</h1> 

    </div><!-- /header --> 

    <div data-role="content"> 
    <!---- BUTTON ----> 
      <div>some content</div> 
      <a href="#sub-page" data-role="button">Next Page</a> 
    </div><!-- /content --> 

    <div data-role="footer" data-position="fixed"> 
     <h4></h4> 
    </div><!-- /footer --> 

</div><!-- /page --> 

<div data-role="page" id="sub-page"" data-add-back-btn="true" data-back-btn-text="Back"> 
    <div data-role="header">   
     <h1>Page Header</h1>  
    </div> 

    <div data-role="content">  
     <p>This is the main content</p> 
    </div> 

    <div data-role="footer"> 
     <h4>Footer</h4> 
    </div>  
</div> 
</body> 

</html> 

嘗試......

+0

我認爲這是由於你的自定義CSS而搞亂了,而且jQuery並沒有從你在頭文件中寫入的代碼中獲取。 – uday 2012-02-08 16:32:11

+0

試過你的代碼,但是這也不起作用... – murratore 2012-02-09 09:15:01

+0

它爲我工作! – uday 2012-02-09 14:48:57