cookie| Beginners
After experimenting and studying the sample program above, you will find that:
1. You are not able to read and display cookies. If you want to look at this cookie you need to specify another string variable that is the same as it:
Document.cookie = cookiename + "=" + Cookievalue + "; expires= "+ cookieexpires;
MyVar = cookiename + "=" + Cookievalue + "; expires= "+ cookieexpires;
document.write (MyVar);
2. The browser uses a different date format:
Netscape uses "GMT" to end, IE uses "UTC" because it can better build a date, as follows:
var expdate = new Date ()
Cookieexpires.settime (Expdate.gettime () + 1 * (* * * 1000))//+1 Day
Cookieexpires.togmtstring ()
When you show the date part
document.write (Expdate.getyear () + "<br>" + expdate.getmonth () + "<br>" + expdate.getdate ());
For the 2000-11-15 date, shown in IE as 2000/10/15, under Netscape display 100/10/15 (note: Some of the lower versions of the
Netscape browser's Y2K problem)
In the example, you see a section like the following:
if (Platform = = "Mac") {
Lastvisit = lastvisit-(24 * 60 * 60 * 1000)
}
But I can't detect it.
Date objects have getdate and Getday methods, and the second method returns the index number of the week's transit.
----------------------------------------
Knowing this, basically there is no problem (now you can take a look at homepage.htm)
[Translator: Copy the last sample code in this article to a text file and save the HTM format, and then run]
The last thing to say is that this is not only a dedicated JS script, if you want to use it on your Web page you have to minimize the use of different browsers to test it and notice their version, many of the scripting program contains browser type detection and a large number of if...else statements to handle this difference.
Sample page homepage.htm source code
=======================================