Search code examples
tapestryonbeforeunload

Is it possible to use Tapestry PageLink and onBeforeOnLoad together?


I'm looking to check the page for changes and alerting the user before they leave if items have not been saved. Is it possible to use onBeforeOnLoad with a PageLink from Tapestry? I've tried and so far have had no luck. Thanks.


Solution

  • Assuming you meant onbeforeunload, which is javascript and wouldn't have anything do with your page link. Instead, add a script tag at the end of your page with the snippet below:

    <script type="text/javascript">
    window.onbeforeunload = function() {
        return true;
    };
    </script>
    

    See this answer for more info.