How to overcome browser compatibility using javascript?
I have the following javascript in one of my .aspx page
window.onbeforeunload = function(evt)
{
if (typeof evt == 'undefined')
{
evt = window.event;
}
if (evt)
{
__doPostBack('', 'MyButtonClick');
}
}
This is ge开发者_高级运维tting fired if i am working with IE but not with crome or firefox 4, but working fine in firefox 3.6.3.
Please Help!
Use JQuery:
<head>
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.6.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(function () {
$(window).unload(function () {
alert('bye');
});
alert('hi');
});
</script>
</head>
精彩评论