jquery - Call a javascript function on tab /browser close not on reload -


i have issue . trying clear cookie value on tab close. , have created function clears value on page reload . tried solution stack-overflow question

function getcookie(name) {   var value = "; " + document.cookie;   var parts = value.split("; " + name + "=");   if (parts.length == 2) return parts.pop().split(";").shift(); } function setcookie(cname, cvalue, exdays) {     var d = new date();     d.settime(d.gettime() + (exdays * 24 * 60 * 60 * 1000));     var expires = "expires=" + d.toutcstring();     document.cookie = cname + "=" + cvalue + "; " + expires+"; path=/"; } function unloadpage() {      var check=getcookie('mycookie')     if(check)     setcookie('mycookie','','-2');  } $(document).ready(function() {     window.onbeforeunload = unloadpage; }); 

function working problem it clearing cookie on page reload . want clear cookie if user close window.

thanks.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -