# 请兄弟帮一下忙,,,我这个程序,,哪里出问题了,,,

danny1984 2004-05-08 05:30:08
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
function initialize(){
state=0
if(document.all && !document.getElementById){
div0=document.all["d0"]
div1=document.all["d1"]
div2=document.all["d2"]
browser="ie4"
}else if(document.getElementById){
div0=document.getElementById("d0")
div1=document.getElementById("d1")
div2=document.getElementById("d2")
browser="dom1"
}else{
browser="unknown"
return
}
divs=new Array(div0,div1,div2)
divstyles=new Array(div0.style,div1.style,div2.style)
}function moveParagraphs(){
for(var i=0;i<divstyles.length;++i){
var x=math.random()*400
var y=math.random()*400
moveDivto(i,x,y)
}
}
function moveDivto(i,x,y){
if(browser=="ie4"){
divStyles[i].posLeft=x
divStyles[i].posTop=y
}else if(browser=="dom1"){
divStyles[i].left=x
divstyles[i].top=y
}
}
function slideText(n){
divstyles[n].visibility="visible"
var max=(n+1)*100
for(var i=0;i<max;++i){
setTimeout("moveDivTo("+n+","+i+","+max+")",500)
}
}
function italicize(){
divStyles[0].fontstle="italic"
divstyles[1].fontstyle="italic"
divStyles[2].fonstyle="italic"
}
function applyDHTML(){
if(browser=="unknown"){
alert("sorry your browser does not provide sufficient dhtml suppport to run this example.")
return
}
switch(state)
{
divstyles[0].fontsize= "x-small";
divstyles[0].fontStyle = "italic";
divstyles[1].fontsize = "medium";
divStyles[1].fontVariant = "small-caps";
divstyles[2].fontsize ="x=large";
divstyles[2].fontFamily ="courier";

}
++state
}

</script>
<form >
<input type="BUTTON" value="Apply dhtml style"
onClick="applyDHTML()">
</FORM>
<DIV ID="d0" style="position:absolute;top:50px">sample text 1</DIV>
<DIV ID="d1" style="position:absolute;top:100px">sample text 2</DIV>
<DIV ID="d2" style="position:absolute;top:150px">sample text 3</DIV>
</body>
</html>
...全文
10 1 点赞 打赏 收藏 举报

1 条回复

52juanjuan 2004-05-08
switch(state)
{
divstyles[0].fontsize= "x-small";
divstyles[0].fontStyle = "italic";
divstyles[1].fontsize = "medium";
divStyles[1].fontVariant = "small-caps";
divstyles[2].fontsize ="x=large";
divstyles[2].fontFamily ="courier";

}
switch()后面要用case state="state.."

function applyDHTML(){
if(browser=="unknown")
{
alert("sorry your browser does not provide sufficient dhtml suppport to run this example.")
return
}
switch(state)
{
case "1":divstyles[0].fontsize= "x-small";break;
case "2": divstyles[0].fontStyle = "italic";break;
case "3": divstyles[1].fontsize = "medium";break;
case "4": divStyles[1].fontVariant = "small-caps";break;
case "4": divstyles[2].fontsize ="x=large";break;
case "4":divstyles[2].fontFamily ="courier";break;

}
++state;
}
• 打赏
• 举报

8.5w+

Web 开发 JavaScript

2004-05-08 05:30