What do these jQuery statements mean or what do they do?
What exactly does the below jQuery statements mean or what do they do?
$(window).focus(ma开发者_C百科inWindowFocus);
$(window).unbind('focus', mainWindowFocus);
This is in relation to main window and a child/popup window.
function mainWindowFocus() {
if (popUpWindow && !popUpWindow.closed) {
popUpWindow.focus();
} else {
popUpWasClosed();
}
}
$(window).focus(mainWindowFocus);
This statement will bind the focus event
to the window
and attaches the function mainWindowFocus
as event handler.
$(window).unbind('focus',mainWindowFocus);
This statement will explicitly remove the function mainWindowFocus
from the event handlers for the focus event
, which are bound to the window
.
精彩评论