请高手帮我解释下 下面的代码 我是刚学javascript不久,希望帮我解释下每行的代码,将不胜感激!
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/ext-core.js" type="text/javascript"></script>
<script src="js/FP.js" type="text/javascript"></script>
<title>战斗机</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
background-color:#000000;
}
.plane{
position:absolute;
background-image: url(img/MyPlaneFrames.png);
background-repeat: no-repeat;
height: 24px;
width: 24px;
}
.heli{
position:absolute;
background-image: url(img/bigheli.png);
background-repeat: no-repeat;
height: 32px;
width: 15px;
}
.score{
color:#FFCC00;
font-size:12px;
position:absolute;
top:5px;
left:5px;
z-index:999;
font-weight:bold;
}
.r{background-position: -48px 0px;}
.l{background-position: -24px 0px;}
.m{background-position: 0px 0px;}
.contain{
position:relative;
height: 300px;
width: 250px;
border: thin solid #FFFF00;
overflow:hidden;
margin-top:20px;
margin-left:auto;
margin-right:auto;
}
.bg {
background-image: url(img/back_water.png);
position:relative;
float:left;
}
.map{
position:absolute;
background-image: url(img/cd.png);
background-repeat: no-repeat;
height: 32px;
width: 32px;
}
.bullet{
position:absolute;
background-image: url(img/bullet_straight.png);
background-repeat: no-repeat;
height: 8px;
width: 5px;
}
.explosion
{background-image: url(img/explosion.png);
background-repeat: no-repeat;
height: 32px;
width: 32px;
position:absolute;
}
.exp0
{background-position: 0px 0px;}
.exp1
{background-position: -32px 0px;}
.exp2
{background-position: -64px 0px;}
.exp3
{background-position: -96px 0px;}
.exp4
{background-position: -130px 0px;}
.tips{
position:absolute;
z-index:999;
top:80px;
left:50px;
width: 140px;
}
.tips .title{
padding:5px 0;
color:#FFFF00;
font-size:14px;
font-weight:bold;
text-align:center;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #FFFFCC;
}
.tips .msg{
margin:4px 0px;
color:#FFFF00;
font-size:12px;
}
.copyright{
color:#FFFF99;
margin-top:10px;
margin-left:auto;
margin-right:auto;
width:250px;
}
-->
</style>
</head>
<body>
<div class="contain" id="contain">
<div class="score">分数:<span id="score">0</span></div>
<div class="tips" id="tips">
<div class="title" id="tipTitle">JS飞机游戏</div>
<div class="msg" id="tipbody">
作者:sujie<br/>
时间:2010-12-25<br/>
版本:v1.0<br/>
说明:按空格键开始,暂停,W-S-A-D控制上下左右,J发射子弹
</div>
</div>
<div class="tips" id="tips"></div>
</div>
<div class="copyright">游戏说明:<br />按空格键开始,暂停,继续,重新开始<br/>W-S-A-D控制上-下-左-右<br/>J发射子弹</div>
</body>
</html><script>Ext.onReady(function(){FP.Mrg.init();});</script> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/ext-core.js" type="text/javascript"></script>
<script src="js/FP.js" type="text/javascript"></script>
<title>战斗机</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
background-color:#000000;
}
.plane{
position:absolute;
background-image: url(img/MyPlaneFrames.png);
background-repeat: no-repeat;
height: 24px;
width: 24px;
}
.heli{
position:absolute;
background-image: url(img/bigheli.png);
background-repeat: no-repeat;
height: 32px;
width: 15px;
}
.score{
color:#FFCC00;
font-size:12px;
position:absolute;
top:5px;
left:5px;
z-index:999;
font-weight:bold;
}
.r{background-position: -48px 0px;}
.l{background-position: -24px 0px;}
.m{background-position: 0px 0px;}
.contain{
position:relative;
height: 300px;
width: 250px;
border: thin solid #FFFF00;
overflow:hidden;
margin-top:20px;
margin-left:auto;
margin-right:auto;
}
.bg {
background-image: url(img/back_water.png);
position:relative;
float:left;
}
.map{
position:absolute;
background-image: url(img/cd.png);
background-repeat: no-repeat;
height: 32px;
width: 32px;
}
.bullet{
position:absolute;
background-image: url(img/bullet_straight.png);
background-repeat: no-repeat;
height: 8px;
width: 5px;
}
.explosion
{background-image: url(img/explosion.png);
background-repeat: no-repeat;
height: 32px;
width: 32px;
position:absolute;
}
.exp0
{background-position: 0px 0px;}
.exp1
{background-position: -32px 0px;}
.exp2
{background-position: -64px 0px;}
.exp3
{background-position: -96px 0px;}
.exp4
{background-position: -130px 0px;}
.tips{
position:absolute;
z-index:999;
top:80px;
left:50px;
width: 140px;
}
.tips .title{
padding:5px 0;
color:#FFFF00;
font-size:14px;
font-weight:bold;
text-align:center;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #FFFFCC;
}
.tips .msg{
margin:4px 0px;
color:#FFFF00;
font-size:12px;
}
.copyright{
color:#FFFF99;
margin-top:10px;
margin-left:auto;
margin-right:auto;
width:250px;
}
-->
</style>
</head>
<body>
<div class="contain" id="contain">
<div class="score">分数:<span id="score">0</span></div>
<div class="tips" id="tips">
<div class="title" id="tipTitle">JS飞机游戏</div>
<div class="msg" id="tipbody">
作者:sujie<br/>
时间:2010-12-25<br/>
版本:v1.0<br/>
说明:按空格键开始,暂停,W-S-A-D控制上下左右,J发射子弹
</div>
</div>
<div class="tips" id="tips"></div>
</div>
<div class="copyright">游戏说明:<br />按空格键开始,暂停,继续,重新开始<br/>W-S-A-D控制上-下-左-右<br/>J发射子弹</div>
</body>
</html><script>Ext.onReady(function(){FP.Mrg.init();});</script> 展开
展开全部
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
//标志位,用来判断是否要初始化
var showFlag = false;
//计算器内的值
var paren = "";
//点击触发的事件函数
function fun(cmd){
//获得id为txt的文本框的对象
var obj = document.getElementById("txt");
//如果showFlag为true,则初始化
if(showFlag){
//文本框的内容清空
obj.value = "";
//计算器内的值paren清空
paren = "";
//标志位设为false
showFlag = false;
}
//计算器内的值paren加上点击的数字重新赋给paren
paren = paren + cmd;
//如果点的是0-9这些数字,则把文本框的内容设成点中的数字
if(cmd=="0" || cmd=="1" || cmd=="2" || cmd=="3" || cmd=="4" || cmd=="5" || cmd=="6" || cmd=="7" || cmd=="8" || cmd=="9"){
obj.value = cmd;
}
}
//计算函数
function count(){
//获得id为txt的文本框的对象
var obj = document.getElementById("txt");
//这里试图捕获一个异常
try{
//把计算器内的值paren放入文本框中,eval的作用就是把字符串转为可以执行的JS代码,进行数值计算
obj.value =eval(paren );
}catch(e){
//这里处理异常
}
//标志位设为true
showFlag = true;
}
//-->
</SCRIPT>
<BODY>
<TABLE border=1>
<TR>
<TD colspan="4" align="center"><input type="text" name="txt" value="" readonly style="text-align:right"></TD>
</TR>
<TR>
<!--onclick事件是点击触发fun()函数,并把参数传入函数中 -->
<TD align="center"><input type="button" name="btn" value=" 7 " onclick="fun('7');"></TD>
<TD align="center"><input type="button" name="btn" value=" 8 " onclick="fun('8');"></TD>
<TD align="center"><input type="button" name="btn" value=" 9 " onclick="fun('9');"></TD>
<TD align="center"><input type="button" name="btn" value=" + " onclick="fun('+');"></TD>
</TR>
<TR>
<TD align="center"><input type="button" name="btn" value=" 4 " onclick="fun('4');"></TD>
<TD align="center"><input type="button" name="btn" value=" 5 " onclick="fun('5');"></TD>
<TD align="center"><input type="button" name="btn" value=" 6 " onclick="fun('6');"></TD>
<TD align="center"><input type="button" name="btn" value=" - " onclick="fun('-');"></TD>
</TR>
<TR>
<TD align="center"><input type="button" name="btn" value=" 1 " onclick="fun('1');"></TD>
<TD align="center"><input type="button" name="btn" value=" 2 " onclick="fun('2');"></TD>
<TD align="center"><input type="button" name="btn" value=" 3 " onclick="fun('3');"></TD>
<TD align="center"><input type="button" name="btn" value=" * " onclick="fun('*');"></TD>
</TR>
<TR>
<TD align="center"><input type="button" name="btn" value=" 0 " onclick="fun('0');"></TD>
<TD align="center"><input type="button" name="btn" value=" = " onclick="count();"></TD>
<TD align="center"><input type="button" name="btn" value=" . " onclick="fun('.');"></TD>
<TD align="center"><input type="button" name="btn" value=" / " onclick="fun('/');"></TD>
</TR>
</TABLE>
</BODY>
</HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
//标志位,用来判断是否要初始化
var showFlag = false;
//计算器内的值
var paren = "";
//点击触发的事件函数
function fun(cmd){
//获得id为txt的文本框的对象
var obj = document.getElementById("txt");
//如果showFlag为true,则初始化
if(showFlag){
//文本框的内容清空
obj.value = "";
//计算器内的值paren清空
paren = "";
//标志位设为false
showFlag = false;
}
//计算器内的值paren加上点击的数字重新赋给paren
paren = paren + cmd;
//如果点的是0-9这些数字,则把文本框的内容设成点中的数字
if(cmd=="0" || cmd=="1" || cmd=="2" || cmd=="3" || cmd=="4" || cmd=="5" || cmd=="6" || cmd=="7" || cmd=="8" || cmd=="9"){
obj.value = cmd;
}
}
//计算函数
function count(){
//获得id为txt的文本框的对象
var obj = document.getElementById("txt");
//这里试图捕获一个异常
try{
//把计算器内的值paren放入文本框中,eval的作用就是把字符串转为可以执行的JS代码,进行数值计算
obj.value =eval(paren );
}catch(e){
//这里处理异常
}
//标志位设为true
showFlag = true;
}
//-->
</SCRIPT>
<BODY>
<TABLE border=1>
<TR>
<TD colspan="4" align="center"><input type="text" name="txt" value="" readonly style="text-align:right"></TD>
</TR>
<TR>
<!--onclick事件是点击触发fun()函数,并把参数传入函数中 -->
<TD align="center"><input type="button" name="btn" value=" 7 " onclick="fun('7');"></TD>
<TD align="center"><input type="button" name="btn" value=" 8 " onclick="fun('8');"></TD>
<TD align="center"><input type="button" name="btn" value=" 9 " onclick="fun('9');"></TD>
<TD align="center"><input type="button" name="btn" value=" + " onclick="fun('+');"></TD>
</TR>
<TR>
<TD align="center"><input type="button" name="btn" value=" 4 " onclick="fun('4');"></TD>
<TD align="center"><input type="button" name="btn" value=" 5 " onclick="fun('5');"></TD>
<TD align="center"><input type="button" name="btn" value=" 6 " onclick="fun('6');"></TD>
<TD align="center"><input type="button" name="btn" value=" - " onclick="fun('-');"></TD>
</TR>
<TR>
<TD align="center"><input type="button" name="btn" value=" 1 " onclick="fun('1');"></TD>
<TD align="center"><input type="button" name="btn" value=" 2 " onclick="fun('2');"></TD>
<TD align="center"><input type="button" name="btn" value=" 3 " onclick="fun('3');"></TD>
<TD align="center"><input type="button" name="btn" value=" * " onclick="fun('*');"></TD>
</TR>
<TR>
<TD align="center"><input type="button" name="btn" value=" 0 " onclick="fun('0');"></TD>
<TD align="center"><input type="button" name="btn" value=" = " onclick="count();"></TD>
<TD align="center"><input type="button" name="btn" value=" . " onclick="fun('.');"></TD>
<TD align="center"><input type="button" name="btn" value=" / " onclick="fun('/');"></TD>
</TR>
</TABLE>
</BODY>
</HTML>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询