Displaying “New to You” Messages

You can use cookies and JavaScript to alert frequent visitors to your site to items that are new to them. This gives the user a more personalized experience when they visit your site, making it a smarter and friendlier place. Scripts 10.9, 10.10, and 10.11 add a little “New!” image to the beginning of lines when the cookie says that a line has been added since the last time the visitor was there (Figure 10.9). Again, you’ll see familiar code from previous examples in this chapter.

Figure 10.9. JavaScript can ask a cookie when you’ve last visited a site and flag new items for you.

To display a “New to You” ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.