JavaScript News Sticker

Few days ago I saw this neat Flash news sticker. It changed news previews every 6-7sec, background was image from news and it had soft black transparent line on which news title and description were shown.
I liked it a lot but it was in flash and I hate flash, so I decided to create JavaScript version of that news sticker.

Download

Latest builds

Simple Demonstration


How does it work?

Include required JavaScript

Before we start we need to include required JS files in our html document. Best place to do this is between head tags. JS News Sticker requires Prototype.




Defining the sticker box

We will create html structure where we want sticker to be placed. Structure should always look like this:

Content will be copied in this structure.

Generated content

Sticker relies on html list for content. You need to create a list that looks something like this:


You will notice that every list element (li) has 3 components, title (h3), description (p) and background (div). Each of these components has it’s own unique ID. Title id would be title_ fallowed by the number (position in the list) first one is 1, second 2 and so on (notice, no zero element). Same rule applies for description and background, ID prefix for description is text_ and for background bg_.
You can create this list however you wish, static, php generated… it doesn’t matter. Sticker will be created based on this list.

Init news sticker

Last thing we need to do is call load function from sticker object. The best place to do this is just before last body tag. It should look like this:


Now you are all done and ready to go ;)

Download

Latest builds

6 Responses to "JavaScript News Sticker"

2 | Anas

November 6th, 2007 at 1:18 pm

Avatar

Nice work. But there Shivering when the news change, and can you add next privous button,
I’m Very interested.

Thank you.

3 | Naufal

April 16th, 2008 at 9:39 am

Avatar

It’s Great buddy !

4 | Giordano

May 21st, 2008 at 6:12 pm

Avatar

I’m very interested. There’s any chance of a new version without the Shivering when the news change.

Thank you!

5 | Matt

May 23rd, 2008 at 8:52 pm

Avatar

Yeah, im looking to use this - but could you add buttons on it like 1 - 2 - 3 - 4 - 5

Like seen at http://www.thecgs.com

6 | Vladimir Cvetic

August 6th, 2008 at 2:52 pm

Avatar

Don’t get your hopes up. I doubt I will be updating this anytime soon.

You are welcome to use it as you like, make modifications to it, even start your own project based on this… But I don’t have time or will to continue on this.

Comment Form