Html文件未在模拟器中运行
我开发了一个html文件。 该index.html运行在webview上,并执行操作,但是当导入到android文件时,只显示UI但不执行操作。 感谢您的帮助。
这是我的代码
enter code here
``BrainVita Game .marble {width:30px; 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>
</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>
既然你正在谈论一个行动,我假设你在你的HTML文件中使用JavaScript。 为了让JavaScript在你的webview中工作,你需要调用webview.getSettings().setJavaScriptEnabled(true);