I'd like to check if the current browser supports the onbeforeunload event.
The common javascript way to do this does not seem to work:
if (window.onbeforeunload) {
alert('yes');
}
else {
alert('no');
}
Actually, it only checks whether some handler has been attached to the event.
Is there a way to detect if onbeforeunload is supported without detecting the particular browser name?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…