Javascript uses cookies to display the DIV prompt box only once _ javascript tips-JS tutorial

Source: Internet
Author: User
This article mainly introduces how JavaScript uses cookies to display a DIV prompt box only once. It involves JavaScript's cookie-based flag-based techniques for controlling the modification of page element styles, for more information about how to use cookie to display a DIV prompt box only once, see the example in this article. We will share this with you for your reference. The details are as follows:

The JavaScript cookie technology is used here to control the prompt DIV displayed only once on the webpage, that is, it is displayed when the user opens the webpage for the first time and automatically hidden for the second time, it improves the user experience and does not bother users. Using Cookies, we can do a lot of things to get started.

The running effect is as follows:

The Online Demo address is as follows:

Http://demo.jb51.net/js/2015/js-cookie-p-dlg-show-once-codes/

The Code is as follows:

 Cookie, only display the DIV prompt box onceScript function cookiesave (n, v, mins, dn, path) {if (n) {if (! Mins) mins = 365*24*60; if (! Path) path = "/"; var date = new Date (); date. setTime (date. getTime () + (mins * 60*1000); var expires = "; expires =" + date. toGMTString (); if (dn) dn = "domain =" + dn + ";"; document. cookie = n + "=" + v + expires + ";" + dn + "path =" + path ;}} function cookieget (n) {var name = n + "="; var ca = document. cookie. split (';'); for (var I = 0; I
 
  

I hope this article will help you design JavaScript programs.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.