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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -