简体   繁体   English

检查Cookie而无需重新加载

[英]Check cookie with no reloading

I need to find way to delete onclick after function end, or check coockie livetime or if you have another soulotion I am here to hear. 我需要找到在函数结束后删除onclick的方法,或者检查coockie的直播时间,或者您是否还有其他灵魂要在这里听到。

I want to do after function fail or success, onclick="play()" will not pop up again without reloading the page. 我想在功能失败或成功后执行,不重新加载页面就不会再次弹出onclick =“ play()”。 My code: 我的代码:

  <script> 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+ ";domain=.SDS.net;path=/";} function getCookie(cname){var name=cname+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1);} if(c.indexOf(name)==0){return c.substring(name.length,c.length);}}return"";} var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); var installed = getCookie("installed"); var failed = getCookie("failed"); if (failed == '3') { } else { if (installed == '') { if(isChrome && !isMobile){ function play(){ alert('Download Extension bla bla bla '); chrome.webstore.install('https://chrome.google.com/webstore/detail/ID',success, fail); } } } } function fail(){ setCookie("failed",3,232323) console.log('Coockie Failed Updated'); location.reload(); } function success(){ setCookie("installed",1,232323); console.log('Coockie Installed Updated'); location.reload(); } </script> 
 <div class="test" onclick="play()"></div> 

Try this 尝试这个

$(".test").prop("onclick", null); $(“。test”)。prop(“ onclick”,null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM