TAILIEUCHUNG - Học JavaScript qua ví dụ part 81

Xóa một Cookie Nếu bạn muốn xóa một tập tin cookie cho trang hiện tại, thiết lập ngày hết hạn của cookie để một ngày sớm hơn ngày hiện tại. Điều này sẽ gây ra các cookie bị xóa khi phiên họp kết thúc. | 710 Chapter 16 Cookies Figure When the user clicks the See Cookie button all cookies are retrieved. Figure After the user clicks the button the color of the page changes based on the cookie that was sent. Deleting a Cookie If you want to delete a cookie for the current page set the expiration date of the cookie to a date earlier than the current date. This will cause the cookie to be deleted when the session ends. EXAMPLE html head title Delete Cookie title head script type text javascript var i 0 1 function delCookie cookieName 2 cookieName expires Thu 01-Jan-1970 00 00 01 GMT alert Cookie was deleted seeCookie From the Library of Creating a Cookie with JavaScript 711 EXAMPLE continued 3 function seeCookie if alert No cookies return false else 4 var myCookie if i 5 myCookie i .split 0 i Increase the index value to see the next cookie else alert No more cookies script head 6 body onLoad seeCookie div align center h2 Got milk h2 7 form name form1 Is this the cookie you want to delete br input type text name cookietype p 8 input type radio name radio value choice 9 onClick delCookie Yes input type radio name radio value choice 10 onClick seeCookie No p form div body html EXPLANATION 1 The function called delCookie will remove a requested cookie. The name of the cookie cookieName is passed as a parameter to the function. Continues From the Library of 712 Chapter 16 Cookies EXPLANATION continued 2 The expiration date of the cookie is set to the beginning of UNIX time also called epoch time January 1 1970. Certainly this date has passed and the cookie will be deleted. After the cookie has been deleted the seeCookie function will be called and the user will be presented with another cookie. If he or she clicks the Yes radio button that cookie will be removed. 3 The function called

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.