javascript how to use smoke.js with onbeforeunload?
i am using smoke.js to create some neat alerts :)
the problem comes when i try to use it on the onbeforeunload
event.
i place it like this:
<body onbeforeu开发者_开发百科nload="javascript:tstconfirm();">
but looks like the script gets unloaded or something because the script doesn't work.
if i try:
<body onbeforeunload="javascript:alert('test');">
the alert works.
any ideas on how to fix this ?
thanks
fixed.
<script language="JavaScript">
$(function() {
$(window).bind('beforeunload', function() {
setTimeout(function() {
setTimeout(function() {
$(".black").css('display', 'block');
// or do something else
}, 1000);
},1);
return 'Wait! Save up to $20 Today!';
});
});
</script>
精彩评论