浏览器支持问题??? FF是不支持window.event的!看看这个:http://blog.csdn.net/city22/archive/2006/07/04/873625.aspx 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 上边的就是一个菜单,在IE中能够实现功能,但在FF中不能实现功能,我知道是FF不支持某些语句,怎么把FF不支持的语句部分进行修改成IE和FF都能支持呢? <div align="center" id="Tdiv_1" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(event,0)">教育网站</div>function divControl(e,show){ e=e||event; e.cancelBubble=true; //.cancelBubble=true; var objID=window.event.srcElement.id; var index=objID.indexOf("_"); var mainID=objID.substring(0,index); var numID=objID.substring(index+1); if(mainID=="Tdiv") { if(show==1) { eval("showdiv("+"Div"+numID+")"); } else if(show==0) { eval("hidediv("+"Div"+numID+")"); } else { eval("hidediv("+"Div"+numID+")"); } }} changke18 不行啊,我试过了 ! 终于改好了,太烦了Firefox 下的 clip 不支持 % 号的形式!根据 CSS 2 文档 http://www.w3.org/TR/REC-CSS2/visufx.html#value-def-bottom 所称,<top>, <right>, <bottom>, and <left> may either have a <length> value or 'auto'而 length 的定义是 http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-length 不包括 %注销的部分用 ///// 或 /**** 注释掉了,并在下面一行进行修正,增加部分都标记了 // add ... // end<!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=gb2312" /><title>无标题文档</title><style type="text/css">.menubar{ position: absolute; top: 10px; width: 100px; height: 20px; cursor: default; border-width: 1px; border-style: outset; color: #99ffff; background: #669900;}.menu{ position: absolute; top: 32px; width: 88px; display: none; border-width: 2px; border-style: outset; /**** border-color: white sliver sliver white; */ border-color: white silver silver white; background: #333399; padding: 5px; overflow: hidden;}.menu A{ text-decoration: none; color: #99FFFF;}.menu A:hover { color: #FFFFFF;}</style><script type="text/javascript"><!--function divControl(event, show) { ///// window.event.cancelBubble=true; // add event = window.event || event; // 我感觉这些好像没用 if(event.cancelBubble) { event.cancelBubble = true; } else if (event.stopPropagation) { event.stopPropagation(); } // end //.cancelBubble=true; ///// var objID = window.event.srcElement.id; var objID = (event.srcElement || event.target).id; var index = objID.indexOf('_'); var mainID = objID.substring(0, index); var numID = objID.substring(index + 1); if(mainID == 'Tdiv') { if(show == 1) { ///// eval('showdiv(' + 'Div' + numID + ')'); showdiv('Div' + numID); } else if(show == 0) { ///// eval('hidediv(' + 'Div' + numID + ')'); hidediv('Div' + numID); } else { ///// eval('hidediv(' + 'Div' + numID + ')'); hidediv('Div' + numID); } }}var nbottom = 0, speed = 2;// addvar timerID;// end///// function displayMenu(obj) {function displayMenu(id) { // add var obj = $(id); var px = nbottom / 100 * obj.offsetHeight; // end ///// obj.style.clip="rect(0 100% "+nbottom+"% 0)"; obj.style.clip = 'rect(0, auto, ' + px + 'px, 0)'; nbottom += speed; if(nbottom <= 100) { ///// timerID = setTimeout('displayMenu(' + obj.id + '), 1'); timerID = setTimeout('displayMenu("' + obj.id + '")', 1); } else { clearTimeout(timerID); }}function showdiv(id) { // add var obj = $(id); // end obj.style.display = 'block'; obj.style.clip = 'rect(0 0 0 0)'; nbottom = 5; displayMenu(obj);}function hidediv(id) { nbottom = 0; $(id).style.display = 'none';}function keepstyle(id) { $(id).style.display = 'block';}// addwindow.$ = function(id) { if(typeof id == 'string') { return document.getElementById(id); } return id;}// end--></script></head><body><table border="0" width="400" cellspacing="0" cellpadding="0" style="font-size: 15px;"> <tr> <td width="20%"> <div align="center" id="Tdiv_1" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">教育网站 </div> </td> <td width="20%"> <div align="center" id="Tdiv_2" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">电脑丛书网站 </div> </td> <td width="20%"> <div align="center" id="Tdiv_3" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">新出图书 </div> </td> <td width="20%"> <div align="center" id="Tdiv_4" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">其他网站 </div> </td> </tr> <tr> <td width="20%"> <div align="left" id="Div1" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)"> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a> </div> </td> <td width="20%"> <div align="left" id="Div2" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)"> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a> </div> </td> <td width="20%"> <div align="left" id="Div3" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)"> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a> </div> </td> <td width="20%"> <div align="left" id="Div4" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)"> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a><br /> <a href="#">重庆XX大学</a> </div> </td> </tr></table></body></html> HTML 中的 divControl 需要加一个 event 参数放在前面,IE 使用的是全局的 window.event所以不用加,而 Firefox 需要通过函数将 event 传进去。HTML 中的 keepstyle、hidediv 参数使用 this 或 this.id 都可以 我靠 bao110908 太牛叉了 爱死你了 一道外资公司的面试题 表单中的 this.form, 这里的this和form真正的含义是什么呢? js里面的filter用法? 在使用模态窗口的 showmodaldialog 时,如何在不关闭模态窗口的同时,刷新父页面 window.open的问题,请帮帮忙 急!在NetScape中动态变更select框中的选项 如何得到表格的最后一个td的id <a href="# 窗口之间的传值问题,很怪,搞了很久不知为什么? kindeditor上传图片,怎么默认打开本地图片啊? prototype该用在什么情况下? 关于倒计时清零的问题,请各位来帮帮忙,我弄了一下午都没搞好
</div>function divControl(e,show)
{
e=e||event;
e.cancelBubble=true;
//.cancelBubble=true;
var objID=window.event.srcElement.id;
var index=objID.indexOf("_");
var mainID=objID.substring(0,index);
var numID=objID.substring(index+1);
if(mainID=="Tdiv")
{
if(show==1)
{
eval("showdiv("+"Div"+numID+")");
}
else if(show==0)
{
eval("hidediv("+"Div"+numID+")");
}
else
{
eval("hidediv("+"Div"+numID+")");
}
}
}
<html xmlns="http: //www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.menubar{
position: absolute;
top: 10px;
width: 100px;
height: 20px;
cursor: default;
border-width: 1px;
border-style: outset;
color: #99ffff;
background: #669900;
}
.menu{
position: absolute;
top: 32px;
width: 88px;
display: none;
border-width: 2px;
border-style: outset;
/**** border-color: white sliver sliver white; */
border-color: white silver silver white;
background: #333399;
padding: 5px;
overflow: hidden;
}
.menu A{
text-decoration: none;
color: #99FFFF;
}
.menu A:hover {
color: #FFFFFF;
}
</style><script type="text/javascript">
<!--
function divControl(event, show) {
///// window.event.cancelBubble=true;
// add
event = window.event || event; // 我感觉这些好像没用
if(event.cancelBubble) {
event.cancelBubble = true;
} else if (event.stopPropagation) {
event.stopPropagation();
}
// end //.cancelBubble=true; ///// var objID = window.event.srcElement.id;
var objID = (event.srcElement || event.target).id; var index = objID.indexOf('_');
var mainID = objID.substring(0, index);
var numID = objID.substring(index + 1);
if(mainID == 'Tdiv') {
if(show == 1) {
///// eval('showdiv(' + 'Div' + numID + ')');
showdiv('Div' + numID);
} else if(show == 0) {
///// eval('hidediv(' + 'Div' + numID + ')');
hidediv('Div' + numID);
} else {
///// eval('hidediv(' + 'Div' + numID + ')');
hidediv('Div' + numID);
}
}
}
var nbottom = 0, speed = 2;// add
var timerID;
// end
///// function displayMenu(obj) {
function displayMenu(id) {
// add
var obj = $(id);
var px = nbottom / 100 * obj.offsetHeight;
// end ///// obj.style.clip="rect(0 100% "+nbottom+"% 0)";
obj.style.clip = 'rect(0, auto, ' + px + 'px, 0)'; nbottom += speed;
if(nbottom <= 100) {
///// timerID = setTimeout('displayMenu(' + obj.id + '), 1');
timerID = setTimeout('displayMenu("' + obj.id + '")', 1);
} else {
clearTimeout(timerID);
}
}function showdiv(id) {
// add
var obj = $(id);
// end obj.style.display = 'block';
obj.style.clip = 'rect(0 0 0 0)';
nbottom = 5;
displayMenu(obj);
}function hidediv(id) {
nbottom = 0;
$(id).style.display = 'none';
}function keepstyle(id) {
$(id).style.display = 'block';
}// add
window.$ = function(id) {
if(typeof id == 'string') {
return document.getElementById(id);
}
return id;
}
// end
-->
</script>
</head>
<body>
<table border="0" width="400" cellspacing="0" cellpadding="0" style="font-size: 15px;">
<tr>
<td width="20%">
<div align="center" id="Tdiv_1" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">教育网站
</div>
</td>
<td width="20%">
<div align="center" id="Tdiv_2" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">电脑丛书网站
</div>
</td>
<td width="20%">
<div align="center" id="Tdiv_3" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">新出图书
</div>
</td>
<td width="20%">
<div align="center" id="Tdiv_4" class="menubar" onmouseover="divControl(event, 1)" onmouseout="divControl(event, 0)">其他网站
</div>
</td>
</tr>
<tr>
<td width="20%">
<div align="left" id="Div1" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)">
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a>
</div>
</td>
<td width="20%">
<div align="left" id="Div2" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)">
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a>
</div>
</td>
<td width="20%">
<div align="left" id="Div3" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)">
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a>
</div>
</td>
<td width="20%">
<div align="left" id="Div4" class="menu" onmouseover="keepstyle(this.id)" onmouseout="hidediv(this.id)">
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a><br />
<a href="#">重庆XX大学</a>
</div>
</td>
</tr>
</table>
</body>
</html>
所以不用加,而 Firefox 需要通过函数将 event 传进去。HTML 中的 keepstyle、hidediv 参数使用 this 或 this.id 都可以