Recently, I was working on a project that involved writing some cookie examples. I found that I still have many shortcomings in js, but I need to work hard:
Untitled Document <script><br> function cookie(name, value, options) {<br> if (typeof value ! = 'undefined') { // name and value given, set cookie<br> options = options || {};<br> <br> var expires = '';<br> ) {<br> date = new Date(); date = options.expires;<br> }<br> expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE<br> }<br> var path = options.path ? '; path=' + options.path : '' ; Om var domain = options.Domain? '; Domain =' + options.dain: ''; <br> var secure = options.Secure? '; Secure': '; = ', encodeURIComponent(value), expires, path, domain, secure].join('');<br> } else { // only name given, get cookie<br> var cookieValue = null;<br> if (document.cookie && document.cookie != '') {<br> var cookies = document.cookie.split(';');<br> for (var i = 0; i < cookies.length; i++) { <br> var cookie = jQuery.trim(cookies[i]) ; O // DOES This Cookie String Begin with The name We Want? Ricomponent (cookie.substring ( name.length + 1));<br> </p>
<p> $(document).ready(function(){<br> if(cookie('show')==1)<br> $(".introBuy").css("display", 'none');<br> <br> $("#close").click(function(){<br> $(".introBuy").css("display", 'none');<br> cookie('show',1)<br> });<br> <br>});<br></script>
关闭