读书人

卓越网的有一个效果如何做出来的

发布时间: 2012-03-05 11:54:02 作者: rapoo

卓越网的有一个效果怎么做出来的
把鼠标放到菜单 "所有20类商品 ",会出现一个渐渐放大的效果,我查了源代码,这个链接并没有onmouseover的事件,请教

[解决办法]
链接可以有个ID如:aa
则可以用:
document.getElementById( 'aa ').onmouseover=自定义函数;//函数不能加括号
如:
<a id= "aa " href= " "> 试试 </a>
<script type= "text/javascript ">
function shi(){window.alert( 'OK ');}
document.getElementById( 'aa ').onmouseover=shi;
</script>
[解决办法]
document.getElementById( 'aa ').onmouseover

好象和

<a id= "aa " href= " " onmouseover = "shi() "> 试试 </a>

这样没什么区别?


[解决办法]
一放大的(onclick),小的改一下就行。

<script type= "text/javascript ">
function resize(objid,w,offx,timeout){
var obj=document.getElementById(objid);
if(obj.offsetWidth <w){
obj.style.width=obj.offsetWidth+offx+ 'px ';
obj.style.height=obj.offsetHeight+offx+ 'px ';
setTimeout( 'resize(\ ' '+objid+ '\ ', '+w+ ', '+offx+ ', '+timeout+ ') ',timeout);
}
}
</script>
<div id= "zoom " style= "background-color:#000000;width:100px;height:100px; " onclick= "resize( 'zoom ',500,50,50); "> 此处显示 id "zoom " 的内容 </div>

读书人网 >JavaScript

热点推荐