Forum Moderators: open

Message Too Old, No Replies

New content code

         

dannad11

6:08 pm on Aug 11, 2010 (gmt 0)

10+ Year Member



Hey,

Just wondering if there is any Javascript I can use without others like Ajax etc which will display "New Content" by a link to the next page?
So the viewer will see that new content has been added (since their last visit) to the next page once he/she clicks the link.

Hope that makes sense, it was clearer in my head.

Thanks.

MichaelBluejay

3:43 am on Aug 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi dannad11, and welcome to WebmasterWorld!

Honestly I don't understand your question very well, but showing content selectively based on who's viewing is possible with JavaScript. For example:

(1) Use CSS to hide the new content.
(2) Set a cookie to record the time when a user visits.
(3) When the user visits again, check the cookie date against the new content date.
(4) If there's new content, then unhide the new content.

Here's some content hidden with CSS (step 1 above): <div id=newContent style="display:none">new content goes here</div>

And here's the JavaScript code that would show the content (step 4 above):
<script type="text/JavaScript">
document.getElementById('newContent').style.display='block';
</script>


Of course you'll need to add the code to set, read, and check the cookie. You can Google how to do that with JS.

Another common way to show content selectively is with a server-side scripting language like PHP or Perl, but JS is probably the easiest way for a newbie to implement this feature.