<script type="text/javascript"> var refresh = true; var success = false; $(document).ready(function () { $("a,:input").click(function () { refresh = false; }); //Script for Browser refresh and close... var myEvent = window.attachEvent || window.addEventListener; var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload'; myEvent(chkevent, function (e) { if (refresh == true) { $.ajax( { type: "POST", traditional: true, dataType: "json", async: false, url: '@Url.Action("MyActionMethod", "MyController")', success: function (data) { if (data == "Success") { success = true; } } }); } }); }); </script>
<a id="aTest" href="GoogleMapsAPITest.aspx" onclick="return MyFunction();">Test Here !</a>
function MyFunction() { //add logic here to conditionally return true or false // false means no reloading. return false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)