2012-03-12 56 views
0

我開發了一個HTML文件上運行。該index.html運行在webview上,並執行操作,但是當導入到android文件時,只顯示UI但不執行操作。感謝您的幫助。HTML文件沒有在模擬器

這是我的代碼

enter code here 

``BrainVita遊戲 .marble {寬度:30像素; height:30px; border:0px; position:inherit;頂:0像素; left:0px} .marbleHover {width:30px; height:30px;邊界:2px的; border-color:red} .divclass {border:1px solid blue;寬度:30px;高度:30px; text-align:center;} .board-state-Hover {border:2px solid red; width:30px; height:30px;} .board-state-Active {border:1px solid green;寬度:30PX;高度:30PX;}

<script type="text/javascript" src="http://www.google.com/jsapi"></script> 


<script type="text/javascript"> 
    google.load('jquery', '1.3.2'); 
    google.load('jqueryui', '1.7.2'); 
</script> 

<script type='text/javascript'> 

$(document).ready(function() 
{ 

    $('#reset').click(function() 
    { 
     DrawBoard(); 
    }); 
     DrawBoard(); 
}); 


function DrawBoard() 
{ 

    $('#Brainvita').empty(); 
    var gameBoard = "<table border='0' cellspacing='3' cellpadding='2'>"; 
    for(var rows = 0; rows < 7; rows++) 
    { 
     gameBoard+= "<tr>"; 
     for(var cols = 0; cols < 7; cols++) 
     { 
      var imgId = " id = 'i" + rows + cols + "' "; 
      var divId = " id = 'd" + rows + cols + "' "; 
      var altValue = " alt = 'i" + rows + cols + "' "; 
      if(rows < 3 && cols > 1 && cols < 5) 
      { 
       gameBoard+= GetImageMarble(divId, imgId, altValue); 
      } 
      else if(rows > 1 && rows < 5) 
      { 
       if(rows == 3 && cols == 3) 
       { 
        gameBoard+= GetEmptyMarble(divId); 
       } 
       else 
       { 
        gameBoard+= GetImageMarble(divId, imgId, altValue); 
       } 
      } 
      else if(rows > 4 && cols > 1 && cols < 5) 
      { 
       gameBoard+= GetImageMarble(divId, imgId, altValue); 
      } 
      else 
      { 
       gameBoard+= "<td></td>"; 
      } 
     } 

     gameBoard+= "</tr>"; 
    } 

    gameBoard += "</table>"; 
    $('#Brainvita').html(gameBoard); 
    $("div[id^='d']").addClass('divclass'); 
    $('#Brainvita').removeClass('divclass'); 
    $("img[id^='i']").draggable({ containment: '#Brainvita', 
      revert: 'invalid', 
      tolerance: 'fit', 
      snap: true, 
      snapMode: 'inner', 
      snapTolerance: 5}); 
    $("div[id^='d']").droppable({ 
     accept: function(event) { 
      var returnFlag = false; 
      if(event[0].nodeName == "IMG") 
      { 
       var destId = this.id; 
       var srcId = event[0].id; 
       var destNo = parseInt(destId.substring(1,3)); 
       var srcNo = parseInt(srcId.substring(1,3)); 
       var result = Math.abs(destNo - srcNo); 
       var removeNo = 0; 

       if($(this).length == 1 && result != 0) 
       { 
        switch(result) 
        { 
         case 2: 

          removeNo = ((destNo - srcNo) > 0) ? destNo - 1 : destNo + 1; 
          break;  
         case 20: 

          removeNo = ((destNo - srcNo) > 0) ? destNo - 10 : destNo + 10; 
          break; 
        } 

        if((result == 2 || result == 20) && removeNo != 0) 
        { 
         var elementToBeRemoved = (removeNo < 10) ? "0" + removeNo : removeNo; 

         if($("#i" + elementToBeRemoved).length == 1 && 
         $("#i" + ((destNo < 10) ? "0" + destNo : destNo)).length == 0) 
         { 
          returnFlag = true; 
         } 

        } 
       } 
      } 
      return returnFlag; 
     }, 
     hoverClass: 'board-state-Active', 
     drop: function(event, ui) { 
      var destId = this.id;     
      var srcId = ui.helper.context.id; //event.srcElement.id; 
      var destNo = parseInt(destId.substring(1,3), 10); 
      var srcNo = parseInt(srcId.substring(1,3, 10)); 
      var result = Math.abs(destNo - srcNo); 
      var removeNo = 0; 


      if($(this).length == 1 && result != 0) 
      { 
       switch(result) 
       { 
        case 2: 
         removeNo = ((destNo - srcNo) > 0) ? destNo - 1 : destNo + 1; 
         break;  
        case 20: 
         removeNo = ((destNo - srcNo) > 0) ? destNo - 10 : destNo + 10; 
         break; 
       } 

       if((result == 2 || result == 20) && removeNo != 0) 
       { 
        ui.helper.context.id = "i" + ((destNo < 10) ? "0" + destNo : destNo); 
        ui.helper.context.alt = ui.helper.context.id; 
        var elementToBeRemoved = (removeNo < 10) ? "0" + removeNo : removeNo; 

        if($("#d" + elementToBeRemoved).length == 1) 
        { 
         $("#i" + elementToBeRemoved).remove(); 
         $("#d" + elementToBeRemoved).empty(); 

        } 
       } 
      } 
     } 
    }); 
} 

function GetImageMarble(divId, imgId, altValue) 
{ 
    var imgTag = "<td align='center' valign='middle'><div "; 
    imgTag = imgTag + divId; 
    imgTag = imgTag + "><img "; 
    imgTag = imgTag + altValue + imgId; 
    imgTag = imgTag + " src='"; 
    imgTag = imgTag + "http://2.bp.blogspot.com/_rTqG9Y-vJsM/S02FPRVxU2I/AAAAAAAACsA/Wa7Ne0AgY_w/s320/Red.PNG'"; 
    imgTag = imgTag + " class=\"marble\"></div></td>"; 
    return imgTag; 
} 


function GetEmptyMarble(divId) 
{ 
    return "<td><div " + divId + "></div></td>"; 
} 
</script> 

<table border="0" cellpadding="1" cellspacing="1" style="border: solid 1px green"> 
    <tr> 
     <td align="center"> 
      <button id="reset"> 
       Reset Board</button><br /> 
      <span id="messages"></span> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      &nbsp;</td> 
    </tr> 
    <tr> 
     <td> 
      <div id="Brainvita"> 
       Hello</div> 
     </td> 
    </tr> 
</table> 
<div id="Trace" style="display: none; width: 400px;"> 
    Trace Messages 
</div> 
<div id="adivSample" style="display: none; width: 100px"> 
    Where are you? 
</div> 
<div id="adebug" style="display: none; width: 100px"> 
    Debug Messages Here 
</div> 

+1

意味着什麼類型的動作要發生? – dldnh 2012-03-12 08:56:50

+1

郵政編碼,你早些時候嘗試過什麼? – user370305 2012-03-12 08:57:09

+1

烏拉圭回合後的HTML代碼,什麼ü嘗試爲 – Khan 2012-03-12 09:04:38

回答

1

因爲你是在談論一個動作,我假設你在你的HTML文件中使用JavaScript 。爲了使你的網頁流量的JavaScript的工作,你需要調用webview.getSettings().setJavaScriptEnabled(true);

+0

我已經啓用,但不工作。 – user915267 2012-03-12 09:21:49

+0

你可以發佈一些代碼嗎? – zrgiu 2012-03-12 09:22:55

+0

我發佈了我的代碼。 – user915267 2012-03-12 09:26:48

相關問題