PDA

View Full Version : inheriting events


Dan
18.06.2001, 16:13
Was being a bit lazy so posted my question straight here without searching the web for the answer.

Basically I have a div tag that has a table within it and then a paragraph. I only want to have the div tag as an object and then catch the events onmouseover, out, down etc. without having to add event handlers for the contents of the DIV. e.g:
<pre id=code><font face=courier size=2 id=code><div id="divMenuItem7" class="menuItem" style="top: 197; left: 1; width: 118; height: 23">
<table border="0" width="112" height="23" cellpadding="0" cellspacing="0" align="right">
<tr><td valign="middle"><p class="pMenu"><u>c</u>ontact</p></td></tr>
</table>
</div></font id=code></pre id=code>then in init():<pre id=code><font face=courier size=2 id=code> objMenus[i:k4ihxbx3nw] = new DhtmlObject("divMenuItem" + i, "objMenus[" + i + "]");
objMenus[i:k4ihxbx3nw].obj.onmouseover = menuOver;
objMenus[i:k4ihxbx3nw].obj.onmouseut = menuOut;</font id=code></pre id=code>Now the problem is that the only elements sent to the mouseOver function are the

and the <td>.

I thought about traversing the choldNodes array until I found a div tag with an id but thought there must be an easier way.

<font face='Courier New'><font color=maroon>»» Dan (dan@pupius.net)
»» www.pupius.net || www.endoflow.com</font id=maroon></font id='Courier New'>

Dan
18.06.2001, 18:32
Ok I've got it working using this: <pre id=code><font face=courier size=2 id=code> function menuOver(e){
if(browser.nn) var el = e.target;
else if(browser.ie) var el = window.event.srcElement;
num = null;
while(!num) {
if(el) num = el.id.substr(11,2);
el = el.parentElement;
}
if(num>0 && num < objMenus.length) objMenus[num].obj.className = "menuItemOver";
}</font id=code></pre id=code>Do you know if .parentElement works in IE4? If not is there an equivalent?

<font face='Courier New'><font color=maroon>»» Dan (dan@pupius.net)
»» www.pupius.net || www.endoflow.com</font id=maroon></font id='Courier New'>

Edited by - Dan on 06/18/2001 17:33:11

Icestorm
18.06.2001, 18:38
hi Dan, parentElement should work fine in ie4 :)

-----<font face='Verdana'>
[url="http://e-syed.net/skriptlab/"]v2[/url:nnd8jdwgwg]</font id='Verdana'>
-----

Dan
18.06.2001, 21:34
cool...thanks

<font face='Courier New'><font color=maroon>»» Dan (dan@pupius.net)
»» www.pupius.net || www.endoflow.com</font id=maroon></font id='Courier New'>

Dan
20.06.2001, 09:08
Where can I find a list of all the string object functions? Think that would be a good TIP OF THE DAY :).
It seems there are loads: replace, search, substr, substring. There may be some really powerful ones that I don't know about, I always seem to need to do work arounds.

<font face='Courier New'><font color=maroon>»» Dan (dan@pupius.net)
»» www.pupius.net || www.endoflow.com</font id=maroon></font id='Courier New'>

Icestorm
20.06.2001, 09:19
Lol, that's what I use a javascript reference is for <img src=icon_smile_wink.gif border=0 align=middle>. Those things document much more too, than just string functions. Get a book! Any O'Reilly will cover it well.

<font face='Courier New'>//<font color=navy> ...peut-on etre un saint sans Dieu?</font id=navy></font id='Courier New'>