>  기사  >  웹 프론트엔드  >  一个小问题。。。_html/css_WEB-ITnose

一个小问题。。。_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 12:23:051022검색

这段代码的问题在哪呢?总是提示说onmouseover标签的div属性不被支持。。。
但是我在前面的script中定义了divControl了啊。。。

<!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" /><style type="text/css">.menubar{position:absolute;top:10px;width:100px;height:20px;cursor:default;border-width:1px;border-style:outset;color:#00CCCC;background:#99CC33}.menu{position:absolute;top:32px;width:140px;display:none;border-width:2px;border-style:outset;border-color:#FFFFFF;background:#99CC33;padding:15px}.menu A{text-decoration:none;color:#00FF66}.menu A:hover{color:#FF6666}</style><script language="javascript">function divControl(show){window.event.concelBubble=true;var objID=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{eval("hidediv("+"Div+"+numID+")");}	}	}var nbottom=0,speed=2;function displayMenu(obj){obj.style.clip="rect(0 100% "+nbottom+"% 0)";nbottom+=speed;if(nbottom<=100){timerID=setTimeout("displayMenu("+obj.id+")");}else clearTimeout(timerID);}function showdiv(obj){obj.style.display="block";obj.style.clip="rect(0 0 0 0)";nbottom=5;displayMenu(obj);}function hidediv(obj){nbottom=0;obj.style.display="none";}function keepstyle(obj){obj.style.display="block";}</script><title>无标题文档</title></head><body><table width="400" border="0" align="center" cellpadding="0" cellspacing="0" style="font-size:15px"><tr><td width="20%"><div align="center" id="Tdiv_1" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">教育网站</div></td><td width="20%"><div align="center" id="Tdiv_2" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">电脑丛书</div></td><td width="20%"><div align="center" id="Tdiv_3" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">新出图书</div></td><td width="20%"><div align="center" id="Tdiv_4" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">其他</div></td></tr></tr><tr><td width="20%"><div align="left" id="Div1" class="menu" onmouseover="keepstyle(this)" onmouseout="hidediv(this)"><a href="#">北京大学</a><br><a href="#">北京航空航天大学</a><br><a href="#">北京工商大学</a></div></td></table></body></html>


回复讨论(解决方案)

本帖最后由 net_lover 于 2013-08-02 20:28:24 编辑

<script>  function divControl(show) {    window.event.concelBubble = true;//只有IE支持此写法    var objID = event.srcElement.id;//只有IE支持此写法    var index = objID.indexOf("_");    var mainID = objID.substring(0, index);    var numID = objID.substring(index + 1);    if (mainID == "Tdiv") {      if (show == 1) {        showdiv(document.getElementById("Div" + numID))      }      else {        hidediv(document.getElementById("Div" + numID))      }    }  }  var nbottom = 0, speed = 2, timerID=null;  function displayMenu(obj) {   nbottom += speed;  if (nbottom <= 100) {    timerID = setTimeout(function () {      displayMenu(document.getElementById(obj.id));    }, 0);  }  else clearTimeout(timerID);}function showdiv(obj) {  obj.style.display = "block";  //obj.style.clip = "rect(0 0 0 0)";  nbottom = 5;  displayMenu(obj);}function hidediv(obj) {  nbottom = 0;  obj.style.display = "none";}function keepstyle(obj) {  obj.style.display = "block";}</script>

<script>  function divControl(show) {    window.event.concelBubble = true;//只有IE支持此写法    var objID = event.srcElement.id;//只有IE支持此写法    var index = objID.indexOf("_");    var mainID = objID.substring(0, index);    var numID = objID.substring(index + 1);    if (mainID == "Tdiv") {      if (show == 1) {        showdiv(document.getElementById("Div" + numID))      }      else {        hidediv(document.getElementById("Div" + numID))      }    }  }  var nbottom = 0, speed = 2, timerID=null;  function displayMenu(obj) {   nbottom += speed;  if (nbottom <= 100) {    timerID = setTimeout(function () {      displayMenu(document.getElementById(obj.id));    }, 0);  }  else clearTimeout(timerID);}function showdiv(obj) {  obj.style.display = "block";  //obj.style.clip = "rect(0 0 0 0)";  nbottom = 5;  displayMenu(obj);}function hidediv(obj) {  nbottom = 0;  obj.style.display = "none";}function keepstyle(obj) {  obj.style.display = "block";}</script>
解决不了问题啊。。。

<!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" /><style type="text/css">.menubar{position:absolute;top:10px;width:100px;height:20px;cursor:default;border-width:1px;border-style:outset;color:#00CCCC;background:#99CC33}.menu{position:absolute;top:32px;width:140px;display:none;border-width:2px;border-style:outset;border-color:#FFFFFF;background:#99CC33;padding:15px}.menu A{text-decoration:none;color:#00FF66}.menu A:hover{color:#FF6666}</style><script language="javascript">function divControl(show){window.event.concelBubble=true;var objID=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){		 showdiv(document.getElementById("Div" + numID));		}else{		hidediv(document.getElementById("Div" + numID));		}	}	}var nbottom=0,speed=2;function displayMenu(obj){//obj.style.clip="rect(0 100% "+nbottom+"% 0)";nbottom+=speed;if(nbottom<=100){timerID=setTimeout("displayMenu("+obj.id+")");}else clearTimeout(timerID);}function showdiv(obj){obj.style.display="block";//obj.style.clip="rect(0 0 0 0)";//nbottom=5;//displayMenu(obj);}function hidediv(obj){nbottom=0;obj.style.display="none";}function keepstyle(obj){obj.style.display="block";}</script><title>无标题文档</title></head><body><table width="400" border="0" align="center" cellpadding="0" cellspacing="0" style="font-size:15px"><tr><td width="20%"><div align="center" id="Tdiv_1" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">教育网站</div></td><td width="20%"><div align="center" id="Tdiv_2" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">电脑丛书</div></td><td width="20%"><div align="center" id="Tdiv_3" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">新出图书</div></td><td width="20%"><div align="center" id="Tdiv_4" class="menubar" onmouseover="divControl(1)" onmouseout="divControl(0)">其他</div></td></tr></tr><tr><td width="20%"><div align="left" id="Div1" class="menu" onmouseover="keepstyle(this)" onmouseout="hidediv(this)"><a href="#">北京大学</a><br><a href="#">北京航空航天大学</a><br><a href="#">北京工商大学</a></div><div align="left" id="Div2" class="menu" onmouseover="keepstyle(this)" onmouseout="hidediv(this)"><a href="#">北京大学</a><br><a href="#">北京航空航天大学</a><br><a href="#">北京工商大学</a></div></td></table></body></html>

一开启
obj.style.clip="rect(0 0 0 0)";
IE8测试就没反应,查了msdn,也没找到为啥

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.