I am trying to delete cookies after a person leaves the page or refreshes. I am pretty new at this. Anyone got a working script?
<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
</script>
onbeforeunload isn't cross-browser compatible, and I _think_ it's going to be deprecated.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
If you want data to be deleted when the page is refreshed or they leave the page then simply don't create a cookie in the first place as those are the only situations where a cookie is needed.
Since 25 May 2011, the HTML5 specification states that calls to window.showModalDialog(), window.alert(), window.confirm() and window.prompt() methods may be ignored during this event.
browser makers realize that many sites abuse the procedure to create frustrating interaction aimed at jailing users into a domain, and they are starting to take action. stay tuned folks.
__________________ my site (updated 5/13) STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
Since all those dialogs are for debugging only there shouldn't be any need to have them in the onbeforeunload processing anyway. For testing why your code doesn't work you could always use an older browser that still allows them there if the console doesn't report anything and you can't be bothered to learn how to use the built in debugger.