狐火 不兼容event.srcElement 解决方法

<script language="JavaScript" type="text/JavaScript">
  	    function getEvent() //同时兼容ie和ff的写法
  	    {
  	        if (document.all) return window.event;
  	        func = getEvent.caller;
  	        while (func != null) {
  	            var arg0 = func.arguments[0];
  	            if (arg0) {
  	                if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
  	                    return arg0;
  	                }
  	            }
  	            func = func.caller;
  	        }
  	        return null;
  	    }
        function showMenu(obj){
        //alert()
            /*var ob = event.srcElement;firefox 下的 event.target = IE 下的 event.srcElement*/
            var ob = getEvent();
	        if(ob.tagName.toLowerCase() == "td")
	        {
		        ob = ob.parentNode.childNodes[1].childNodes[0]
	        }
	        if(ob.tagName.toLowerCase() == "a")
	        {
		        ob = ob.parentNode.parentNode.childNodes[1].childNodes[0]
	        }
	        if(obj.style.display =="")
	        {
		        obj.style.display = "none"
		        ob.src ="images/up.gif"
	        }
	        else
	        {
		        obj.style.display = ""
		        ob.src = "images/down.gif"
	        }
        }
        
        function ShowHideList()
			    {
				    if (document.all['mainmenu'].style.display=='none')               
				    {
					    document.all['mainmenu'].style.display='';
					    document.all['frameshow'].src="images/showhiddenp_1.gif";
					    oa_tree.title="隐藏菜单栏";
				    }
				    else
				    {
					    document.all['mainmenu'].style.display='none';
					    document.all['frameshow'].src="images/showhiddenp_2.gif";
					    oa_tree.title="显示菜单栏";
				    }
			    }
	    </script>

你可能感兴趣的:(JavaScript,firefox,target,srcelement)