SYP}{ER
02-01-2003, 03:10 PM
Alright. I'm making a menu and have the following code to show each layer (each layer has an id):
function show (objToFind,idOfTarget){
var left, top;
offx = 0;
offy = 20;
if (!objToFind.onmouseout) objToFind.onmouseout = function () { hide (idOfTarget); }
what = document.getElementById(idOfTarget);
killTOs(idOfTarget);
if (typeof document.all != 'undefined') {
var textRange = document.body.createTextRange();
textRange.moveToElementText(objToFind);
var textRect = textRange.getClientRects()[0];
left = textRect.left;
top = textRect.top;
scrolll = document.body.scrollTop;
} else if (typeof document.getBoxObjectFor != 'undefined') {
var box = document.getBoxObjectFor(objToFind);
left = box.x;
top = box.y+2;
scrolll = document.documentElement.scrollTop;
}
if (ns4){
what.moveTo(left+offx,top+offy+scrolll);
}else{
what.style.top = top+offy+scrolll + 'px';
what.style.left = left+offx + 'px';
}
if (!what.onmouseover) what.onmouseover = function () { killTOs (idOfTarget); }
if (!what.onmouseout) what.onmouseout = function () { hide (idOfTarget); }
}
Now the last 2 lines of the function are part of my problems (the only part I think I need help fixing).
When I try to alert () the value of what.onmouseout (ie: alert (document.getElementById('homeMenu').onmouseout)) I get "function () { killTOs (idOfTarget); }" in the alert box, minus the quotes of course.
Now I'm wondering, how will it know what idOfTarget is when I mouseOver the object?! I really just want the onmouseout to be, for example, killTOs ('homeMenu');
Any ideas?!
function show (objToFind,idOfTarget){
var left, top;
offx = 0;
offy = 20;
if (!objToFind.onmouseout) objToFind.onmouseout = function () { hide (idOfTarget); }
what = document.getElementById(idOfTarget);
killTOs(idOfTarget);
if (typeof document.all != 'undefined') {
var textRange = document.body.createTextRange();
textRange.moveToElementText(objToFind);
var textRect = textRange.getClientRects()[0];
left = textRect.left;
top = textRect.top;
scrolll = document.body.scrollTop;
} else if (typeof document.getBoxObjectFor != 'undefined') {
var box = document.getBoxObjectFor(objToFind);
left = box.x;
top = box.y+2;
scrolll = document.documentElement.scrollTop;
}
if (ns4){
what.moveTo(left+offx,top+offy+scrolll);
}else{
what.style.top = top+offy+scrolll + 'px';
what.style.left = left+offx + 'px';
}
if (!what.onmouseover) what.onmouseover = function () { killTOs (idOfTarget); }
if (!what.onmouseout) what.onmouseout = function () { hide (idOfTarget); }
}
Now the last 2 lines of the function are part of my problems (the only part I think I need help fixing).
When I try to alert () the value of what.onmouseout (ie: alert (document.getElementById('homeMenu').onmouseout)) I get "function () { killTOs (idOfTarget); }" in the alert box, minus the quotes of course.
Now I'm wondering, how will it know what idOfTarget is when I mouseOver the object?! I really just want the onmouseout to be, for example, killTOs ('homeMenu');
Any ideas?!