我写了下面一段代码
但是当我点"动起来"的按纽时候,函数没执行
还有,就是页面一下载,系统提示说"网页上有错误"
希望 大家能帮我改正:
<head>
<script language="javascript">
function txtfocus(){
document.forms[0].txt.focus()
hidden1.style.visibility="visible"
hidden1.style.color="black"
}
function txthide()
{
hidden1.style.visibility="hidden"}
function colorturn(){
hidden1.style.color="red"
}
function sizeturn(){
hidden1.style.fontSize="12PX";
//这里的FONTSIZE的格式要注意哦,是fontSize,其他写法都是错误的 }
function move1(){
hidden1.style.left=parseInt(hidden1.style.left)-20;
if (hidden1.style.left=="0px")
hidden1.style.left="200px";
setTimeout("move1()",200);
}
//就是这一段代码了,margin-left在CSS中的格式是margin-left:但是在JS中就不知道正确格式了,(上面的fontSize属性也是的,在JS中就改变它的写法了)为什么会这样呢?有没有好一点的电子书,能具体讲明白这些统一格式的啊,可以下载来看看,谢谢!
</script>
</head>
<body>
<form>
<input type="text" name="txt" value="">
<input type="button" name="buton" value="选中" onclick="txtfocus()">
<input type="button" name="hide" value="隐藏按纽" onclick="txthide()">
<input type="button" name="color" value="变色" onclick="colorturn()">
<input type="button" name="size" value="变小" onclick="sizeturn()">
<input type="button" name="move" value="动起来" onclick="move1()">
</form>
<div id="hidden1" style="position:absolute;margin-top:200px;left:500px;
visibility:hidden1;">这是一段隐藏的文字,只要选中按纽就可以看到</div></body>
但是当我点"动起来"的按纽时候,函数没执行
还有,就是页面一下载,系统提示说"网页上有错误"
希望 大家能帮我改正:
<head>
<script language="javascript">
function txtfocus(){
document.forms[0].txt.focus()
hidden1.style.visibility="visible"
hidden1.style.color="black"
}
function txthide()
{
hidden1.style.visibility="hidden"}
function colorturn(){
hidden1.style.color="red"
}
function sizeturn(){
hidden1.style.fontSize="12PX";
//这里的FONTSIZE的格式要注意哦,是fontSize,其他写法都是错误的 }
function move1(){
hidden1.style.left=parseInt(hidden1.style.left)-20;
if (hidden1.style.left=="0px")
hidden1.style.left="200px";
setTimeout("move1()",200);
}
//就是这一段代码了,margin-left在CSS中的格式是margin-left:但是在JS中就不知道正确格式了,(上面的fontSize属性也是的,在JS中就改变它的写法了)为什么会这样呢?有没有好一点的电子书,能具体讲明白这些统一格式的啊,可以下载来看看,谢谢!
</script>
</head>
<body>
<form>
<input type="text" name="txt" value="">
<input type="button" name="buton" value="选中" onclick="txtfocus()">
<input type="button" name="hide" value="隐藏按纽" onclick="txthide()">
<input type="button" name="color" value="变色" onclick="colorturn()">
<input type="button" name="size" value="变小" onclick="sizeturn()">
<input type="button" name="move" value="动起来" onclick="move1()">
</form>
<div id="hidden1" style="position:absolute;margin-top:200px;left:500px;
visibility:hidden1;">这是一段隐藏的文字,只要选中按纽就可以看到</div></body>
<head>
<script language="javascript">
function txtfocus(){
document.forms[0].txt.focus()
hidden1.style.visibility="visible"
hidden1.style.color="black"
}
function txthide()
{
hidden1.style.visibility="hidden"}
function colorturn(){
hidden1.style.color="red"
}
function sizeturn(){
hidden1.style.fontSize="12PX";
//这里的FONTSIZE的格式要注意哦,是fontSize,其他写法都是错误的 }
function move1(){
hidden1.style.left=parseInt(hidden1.style.left)-20;
if (hidden1.style.left<="10px")
setTimeout("up1()",200);
else
setTimeout("move1()",200);
} function up1(){
hidden1.style.top=parseInt(hidden1.style.top)-20;
if (hidden1.style.top<="60px")
hidden1.style.top="200px";
setTimeout("up1()",200);
}
</script>
</head>
<body>
<form>
<input type="text" name="txt" value="">
<input type="button" name="buton" value="选中" onclick="txtfocus()">
<input type="button" name="hide" value="隐藏按纽" onclick="txthide()">
<input type="button" name="color" value="变色" onclick="colorturn()">
<input type="button" name="size" value="变小" onclick="sizeturn()">
<input type="button" name="move" value="动起来" onclick="move1()">
</form>
<div id="hidden1" style="position:absolute;margin-top:200px;left:500px;
visibility:hidden ;">这是一段隐藏的文字,只要选中按纽就可以看到</div></body>
hidden1.style.top=parseInt(hidden1.style.top)-20;
if (parseInt(hidden1.style.top)<=60)
hidden1.style.top="200px";
setTimeout("up1()",200);
}<div id="hidden1" style="position:absolute;top:200px;left:500px;
<html>
<head>
<script language="javascript">
function colorarray(){
this.length=colorarray.arguments.length;
for(var i=0;i<this.length;i++)
this[i+1]=colorarray.arguments[i];
}
mycolorarray=new colorarray("white","red","green","bule");
for(var j=1;j<5;j++)
document.write(mycolorarray[j]+"<br>");
colorcode=1;
function colorturn(){
txt.style.color=mycolorarray[colorcode];
if(colorcode==5)
colorcode=0;
colorcode=colorcode+1;
setTimeout("colorturn()",200);
}
</script>
</head>
<body bgcolor="#564729" onload="colorturn()">
<div id="txt">
<center>
<p>天上的星星眨呀眨</p>
</center>
</div>
</body>
</html>
为什么老是出错呢?闪了一边,之后就不闪了?
==>
mycolorarray=new colorarray("white","red","green","blue");
<script language="javascript">
function txtfocus(){
document.forms[0].txt.focus()
hidden.style.visibility="visible"
hidden.style.color="black"
}
function txthide()
{
hidden.style.visibility="hidden"}
function colorturn(){
hidden.style.color="red"
}
function sizeturn(){
hidden.style.fontSize="12PX";
}
function doMove(){
hidden.style.visibility = "visible";
hidden.style.pixelLeft -= 20;
if (hidden.style.pixelLeft < 0)
hidden.style.pixelLeft = 200;
setTimeout("doMove()",200);
}
</script>
</head>
<body>
<form>
<input type="text" name="txt" value="">
<input type="button" name="buton" value="选中" onclick="txtfocus()">
<input type="button" name="hide" value="隐藏按纽" onclick="txthide()">
<input type="button" name="color" value="变色" onclick="colorturn()">
<input type="button" name="size" value="变小" onclick="sizeturn()">
<input type="button" name="move" value="动起来" onclick="doMove()">
</form>
<div id="hidden" style="position:absolute;margin-top:200px;
visibility:hidden; border:1 solid #222222">这是一段隐藏的文字,只要选中按纽就可以看到</div></body>