javascript - Prevent window.onbeforeunload event from being fired while clicking on hyperlinks -
i have page user prompted confirm unloading of page using window.onbeforeunload event handler. message getting fired when there navigation 1 page result of clicking on hyperlink (anchor tag).
how can stop event being fired when hyperlink or anchor tag clicked? code provided below:
<script type="text/javascript"> $(function () { $("a").click(function () { window.onbeforeunload = null; }); $("form").live("submit", submitlistener); function submitlistener(e) { window.onbeforeunload = null; } }); window.onbeforeunload = confirmexit; function confirmexit() { return "your changes lost if not saved..."; } </script> <a title="delete document" class="btn btn-danger" onclick="return confirm('are sure, want delete committee?');" href='@url.action("delete", "managecommittee", new { id =model.id})' style="margin-left:5px;"> <i class="icon-trash icon-white"></i> <span>delete</span> </a> <p>i dont want alert while user click on anchor tag</p>
Comments
Post a Comment