onbeforeunload = myfunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

onbeforeunload = myfunction();

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<a href="https://www.java2s.com">Click here</a>

<script>
window.onbeforeunload = function(event) {
    event.returnValue = "Write something clever here..";
};
</script>//from w  w w .j av  a  2s  .  c o m

</body>
</html>

Related Tutorials