简体   繁体   中英

how alert message to client when the page want refresh?

Hi to all I'm beginner in java script I need to make some alert and shown that when the page want refresh and done some work like counter=0 or delete a file how can I do this by jquery and java script? thank!

Before page load/refresh:

<head>
alert("hello");
</head>

Within body:

<script>
$count= 0;
while ($count < 10 ) {
$count++;
}
alert("counter increased: " + $count + " times");
</script>

You can bind refresh event:

 window.onbeforeunload = function () {
   return 'Post job process not completed yet.';
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM