2012-12-16 54 views
0

我正在使用PhoneGap開發帶有HTML5,CSS和jQuery的iPhone應用程序。但是,我對PhoneGap或MWE的理解似乎存在一些問題。使用PhoneGap顯示'返回'按鈕

我用下面的代碼codeforest.net:

<!DOCTYPE html> 
<html> 
    <head> 
     <title>jQuery Mobile Tutorial on Codeforest.net</title> 
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" /> 
     <script src="http://code.jquery.com/jquery-1.4.3.min.js"></script> 
     <script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script> 
    </head> 

    <body> 

     <!-- Start of first page --> 
     <div data-role="page" id="first"> 

      <div data-role="header"> 
       <h1>First</h1> 
      </div><!-- /header --> 

      <div data-role="content"> 
       <p>The content</p> 
       <p>View internal page called <a href="#second">second</a></p> 
      </div><!-- /content --> 

      <div data-role="footer"> 
       <h4>Page Footer</h4> 
      </div><!-- /footer --> 
     </div><!-- /page --> 


     <!-- Start of second page --> 
     <div data-role="page" id="second"> 

      <div data-role="header"> 
       <h1>Second</h1> 
      </div><!-- /header --> 

      <div data-role="content"> 
       <p>I'm the second content</p> 
       <p><a href="#first">Back to first</a></p> 
      </div><!-- /content --> 

      <div data-role="footer"> 
       <h4>Page Footer</h4> 
      </div><!-- /footer --> 
     </div><!-- /page --> 
    </body> 
</html> 

開始在其單獨的文件中的代碼將導致通緝的行爲(只顯示第一divid="first",該鏈接的第二頁上點擊時在頂部加載一個後退按鈕)。

我想我可以使用PhoneGap將此HTML/CSS/JS示例轉換爲正在運行的iOS應用程序。

我從一開始就遇到的問題是我想有幾個不同的.html文件,它們相互引用。這可以工作,但有一個問題,頭文件中沒有顯示本機back-button

回答

0

答案,張貼由原始提問(作爲更新的問題 - 從來就它搬到這裏,所以它在一個答案):

問題是,應用程序無法從外部鏈接加載代碼。 發現的解決方案在這裏:External links or url doesn't work on phonegap

3

然後創建自己的後退按鈕。

的代碼將創建一個後退按鈕你這個部分:

<a class="ui-btn-left" data-icon="arrow-l" href="javascript:history.back(1) " data-theme="a">Back</a> 

這裏有一個例子的jsfiddle:http://jsfiddle.net/Gajotres/ddsrx/。它使用一個文件與多個頁面,但它也將與幾個單獨的html文件一起使用。

+0

實際的問題是,新的PhoneGap需要外部鏈接的白名單,否則將無法(所有文件從code.jquery.com在我的情況)加載外部文件。 – cherrun