Mouse clicks appear drop-down menu, point other Place, shrink back.
Document.addeventlistener ("MouseDown", function (e) {var target = E.target | | e.srcelement;while (target!! Document & & Target! = Popup) {target = Target.parentnode;} if (target = = document) {popup.hide ();}}, False), where popup is a menu element, Popup.hide () hidden menu
Nav.onclick = function () {
var e = Arguments[0] | | Window.event,
target = e.srcelement? E.srcelement:e.target;
}//Some pieces of code how to explain.
Nav is the name of an element of a page, such as a button or picture, etc.. onclick is the register event for this element. Function inside is the code that executes when clicked. where var e = arguments[0] | | The arguments in window.event is the parameter array of the function, that is, all parameters, and Arguments[0] is the first parameter, the first parameter of the Click event (onclick) in the Firefox browser is the event (click Events Object), But IE is not inside, so to make sure that E is "click event Object" so use "| |". You may just want to know that the variable e here is an event object. This event object has some intrinsic properties, such as E.srcelement, which is the object of the event, in layman's name, click Who, here is the first line of the nav element. E.srcelement only Internet Explorer is effective, and in Firefox it should be: e.target, so target = e.srcelement? e.srcelement:e.target; this line is to make sure The previous target is the event-triggered element, the NAV.
target = E.target | | E.srcelement