PDA

Click to See Complete Forum and Search --> : Mozilla version


dj4uk
Mar 29th, 2004, 04:54 AM
I've got the following code that I use to display context menus on a page.


<script language="JavaScript">
var sOpenMenuID = "";

function DoMenu() {
window.event.cancelBubble = true;
var eSrc = window.event.srcElement;
if ("object" == typeof(document.all[sOpenMenuID]))
{
document.all[sOpenMenuID].style.visibility = "hidden";
if (sOpenMenuID == eSrc.id.replace("popup_link","popup_div"))
{
sOpenMenuID = "";
return false;
}
else
{
sOpenMenuID = "";
}
}

window.event.returnValue = false;
sOpenMenuID = eSrc.id.replace("popup_link","popup_div");
if ("object" == typeof(document.all[sOpenMenuID])) {
var eMenu = document.all[sOpenMenuID];
var eTR = eSrc.parentElement.parentElement.parentElement;
var eTABLE = eTR.parentElement.parentElement;
eMenu.style.left = eTABLE.offsetLeft + eTR.offsetLeft + 32;
eMenu.style.top = eTABLE.offsetTop + eTR.offsetTop + 32;
eMenu.style.visibility = "visible";
}
}
</script>


Can anyone give me any points where to start to have a version that works in Mozilla.

Also does Mozilla support an onclick event within the body tag?

DJ

Acidic
Mar 29th, 2004, 06:09 AM
start of changin document.all[something] to document.getElementById(something)

not sure about the onClick on the body.

definately over SPAN and DIV though.

dj4uk
Mar 29th, 2004, 07:10 AM
Ok thanks for the suggestions.

How about window.event and parentElement - does Mozilla support these?

Acidic
Mar 29th, 2004, 10:52 AM
I'm pretty sure it does yes.

CornedBee
Mar 31st, 2004, 01:10 AM
Not window.event.

There's an event object directly in the event handler though, so if you do
... onclick="DoMenu(event)"...
and give DoMenu an argument that you use instead of window.event you'll be fine, except for the many many incompatibilities of the two objects. I'm also not sure about the srcElement. I think it doesn't exist, I usually pass this in the event handler:
... onclick="DoMenu(event, this)"...