Цитата(Fubu_By @ 25.9.2010, 04:29 ) | | да и там везде timeout=0 |
Вот это и может быть причиной проблем в некоторых браузерах.
Поскольку вы приводите лишь кусок кода, то приходится домысливать, как там у вас устроено все. Вот результат этого «домысливания». Вроде работает. 
| Код | <!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=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function observe(obj, ev, handler) { if (obj.addEventListener) { obj.addEventListener(ev, handler, false); } else { obj.attachEvent("on" + ev, handler); } } function getCurrentElement(e) { if (!e) e = event; return (e.target) ? e.target : e.srcElement; }
t = 0; window.onload = function() { var img = document.getElementById("img"); var picad_div = get_picad_div(); observe(img, 'mouseover', ol_display_ad); observe(img, 'mouseout', ol_hide_ad); observe(picad_div, 'mouseover', ol_display_ad); observe(picad_div, 'mouseout', ol_hide_ad); }
function get_picad_div(el) { return document.getElementById("d"); }
ol_display_ad = function(e) { var el = getCurrentElement(e); display_ad(el); };
ol_hide_ad = function (e) { var el = getCurrentElement(e); hide_ad(el); };
display_ad = function (el) { var d = get_picad_div(el); d.style.display = "block";
d.style.left = el.offsetLeft.toString() + "px"; d.style.top = (el.offsetTop + el.offsetHeight - d.offsetHeight).toString() + "px"; d.style.width = el.offsetWidth.toString() + "px"; show_picad_div(d, 10, 10); }; hide_ad = function (el) { var d = get_picad_div(el); hide_picad_div(d, 10, 10); }; show_picad_div = function (e, timeout, interval) { if (t) clearTimeout(t); t = window.setTimeout(function () { t = 0; var overlay_close = window.setInterval(function () { e.style.height = (e.offsetHeight + 1).toString() + 'px'; e.style.top = (e.offsetTop - 1).toString() + 'px'; if (e.offsetHeight >= 51) { window.clearInterval(overlay_close); } }, interval); }, timeout); };
hide_picad_div = function (e, timeout, interval) { if (t) clearTimeout(t); t = window.setTimeout(function () { t = 0; var overlay_close = window.setInterval(function () { e.style.height = Math.max(e.offsetHeight - 1, 0).toString() + 'px'; e.style.top = (e.offsetTop + 1).toString() + 'px'; if (e.offsetHeight < 2) { window.clearInterval(overlay_close); e.style.display = "none"; } }, interval); }, timeout); }; </script> </head>
<body> <img src="jpg.jpg" alt="" id="img" height="51" /> <div id="d" style="background: red; position: absolute; display: none;">ddddd</div> </body> </html>
|
|