2012-01-04 44 views
1

我正在使用jQuery移動框架在phonegap中創建應用程序。如何在按鈕上加載另一個html文件點擊jquery mobile

在我的index.html文件中我有兩個文本框來接受用戶名和密碼。

當我點擊提交按鈕,它調用一個函數submitBtn(),檢查用戶名和密碼是否正確與否,如果它是正確的,那麼它應該加載我創建'selectOption.html」

一個新的HTML文件

這裏是我的代碼

<script type="text/javascript"> 
    $(document).ready(function() { 
     var userName; 
     var userPassword; 

     $("#submitBtn").click(function() { 
      //alert("HI");  
      userName = $("#UserName").val(); 
      userPassword = $("#Password").val(); 

      if ((!UserName)|| (!userPassword)) { 
       alert("Enter the Details"); 
      } 
      else { 
       if ((userName !="alpha") ||(userPassword !="beta")) { 
        alert('Enter correct username and password'); 
       } 
       else { 
        //here i want to load my selectOption.html file ? 
       }    
      }         
     });       
    }); 
</script> 

<body>下的代碼是

<body> 
    <div data-role="page" id="home">   
     <div data-role="header">    
      <h1>Enter Credential</h1>      
     </div> 

     <div data-role="content"> 
      <label for="UserName">User Name</label> 
      <input type="text" name="UserName" id="UserName" value="" style="width:220px;" /> 

      <label for="Password">Password</label> 
      <input type="password" name="Password" id="Password" value="" style="width:220px;" /> 

      <div id="submitBtn" data-role="button">Submit</div> 
     </div> 
    </div> 
</body> 

功能是GE tting叫,但我怎麼能加載selectOption.html文件?

+0

當你說 「加載另一個文件」,你的意思是「重定向到另一個文件「? – CedX 2012-01-04 14:01:29

回答

0

我找到了答案

加載任何頁面,您可以簡單地做

$.mobile.changePage("yourHTML.html","slideup");

相關問題