怎么控制qq骰子点数:用javascript写一个简单的程序

来源:百度文库 编辑:高考问答 时间:2024/04/28 02:48:40
在静态网页编程中,想用javascript实现一个简单的功能,由于时间仓促,不能自己看着书慢慢学了,请高手帮忙提供详细代码和解释,非常感谢.

建立一个一行三列的表格,当鼠标停在第一行时,第三行显示"abcd",当鼠标停在第二行时,第三行显示"1234",当鼠标停在第三行时,第三行显示"这是第三行".

<table>
<tr onmouseover="ss.innerHTML='abcd';"><td>第一行</td></tr>
<tr onmouseover="ss.innerHTML='1234';"><td>第二行</td></tr>
<tr><td id=ss></td></tr>
</table>

onmouseover事件在鼠标放在单元格上时被激发。

ss.innerHTML='abcd'使id为ss的第三行单元格的内容变为abcd。

明白了没?

<table width="200" border="1">
<tr onmouseover="gogo.innerHTML='abcd';"><td>第一行</td></tr>
<tr onmouseover="gogo.innerHTML='1234';"><td>第二行</td></tr>
<tr><td id="gogo" onmouseover="this.innerHTML='这是第三行';">第三行</td></tr>
</table>

你把我写的这段代码 存成 HTML :

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<style>
body,td { font-size:12px; font-family:宋体}
a:link { color: #ffffff; text-decoration: none}
a:visited { color: #ffffff; text-decoration: none}
a:hover { color: #ff9933; text-decoration: none}
table { border: #000000; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
</style>
<script language="JavaScript">
<!--
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }
}
//-->
</script>
<body>
<div id="title" style="position:absolute; width:100px; height:120px; z-index:1; background-color: #006699; layer-background-color: #006699; border: 1px none #000000">
<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="40" valign="top" bgcolor="#333333" onMouseOver="MM_showHideLayers('menu1','','show')" onMouseOut="MM_showHideLayers('menu1','','hide')"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="40" valign="top" bgcolor="#CCCCCC" onMouseOver="MM_showHideLayers('menu2','','show')" onMouseOut="MM_showHideLayers('menu2','','hide')"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="40" valign="top" bgcolor="#FFFFFF"onMouseOver="MM_showHideLayers('menu3','','show')" onMouseOut="MM_showHideLayers('menu3','','hide')">

<div id="menu1" style="position:absolute; width:100px; height:40px; z-index:2; background-color: #999966; layer-background-color: #999966; border: 1px none #000000; visibility: hidden" onMouseOver="MM_showHideLayers('menu1','','show')" onMouseOut="MM_showHideLayers('menu1','','hide')">
abcd
</div>

<div id="menu2" style="position:absolute; width:100px; height:40px; z-index:2; background-color: #999966; layer-background-color: #999966; border: 1px none #000000; visibility: hidden" onMouseOver="MM_showHideLayers('menu1','','show')" onMouseOut="MM_showHideLayers('menu1','','hide')">
1234
</div>

<div id="menu3" style="position:absolute; width:100px; height:40px; z-index:2; background-color: #999966; layer-background-color: #999966; border: 1px none #000000; visibility: hidden" onMouseOver="MM_showHideLayers('menu1','','show')" onMouseOut="MM_showHideLayers('menu1','','hide')">
这是第三行
</div>
</td>
</tr>
</table>
</div>
</body>
</html>

我的原理:是用层来做!就有点像JS的下拉菜单

btok的方法是不是还得加个onmouseout事件啊?

莫名其妙,这么简单的东西 用得着写这么多代码吗???
td中有onmouseover 和 onmouseout 事件 再追加上显示文字就ok了

btok - 高级经理 六级

真是高人!