0

我写了以下幻灯片菜单: http ://www.julian-urabl.com/webtest/index.html

除了我想添加的一种行为之外,它工作得很好:

如果鼠标没有放在 div 容器“菜单”上,则 Onload,菜单应在 1000 毫秒后收缩。

我考虑过检查,如果鼠标被放置在 div 上并且只有在返回“false”时我会让菜单滑出

setTimeout(function(){slide.style.marginLeft="-140px"},1000);

我对 js 完全陌生,但如果我理解正确,hover、mouseover 和 mouseenter 都不会帮助解决我的问题。谁能帮我?

4

1 回答 1

0

This is what I would do:

Onload, check the location of the mouse (e.g http://www.codelifter.com/main/javascript/capturemouseposition1.html). Though I would suggest you start using jquery for the same.

Once you are at the point where you can get the mouse location, you need to make sure that the mouse if not inside the coordinates of the menu. To do that you can see this.

After that its simple, if the mouse coordinates are inside these coordinates, then don't let the menu slide in, if that is not the case let the menu slide in.

于 2013-09-03T01:33:13.073 回答