Results 1 to 5 of 5

Thread: Mozilla version

  1. #1

    Thread Starter
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Mozilla version

    I've got the following code that I use to display context menus on a page.

    Code:
    <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

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    start of changin document.all[something] to document.getElementById(something)

    not sure about the onClick on the body.

    definately over SPAN and DIV though.
    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131
    Ok thanks for the suggestions.

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

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    I'm pretty sure it does yes.
    Have I helped you? Please Rate my posts.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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)"...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width