mouseover - news headlines

This is a discussion on "mouseover - news headlines" within the JavaScript Forum section. This forum, and the thread "mouseover - news headlines are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Dec 8th, 2007, 16:15
WDH WDH is offline
Junior Member
Join Date: Aug 2007
Location: UK
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
mouseover - news headlines

Hi,
I am trying to create a news headlines section for on my website so that you can mouseover the headline and then the story will appear to the side of it with no clicking involved.

http://s121.photobucket.com/albums/o...t=SANY0023.flv

Here is a video showing the type of thing i am looking for. Any help with code appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 8th, 2007, 16:41
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: mouseover - news headlines

Well this is a reasonably simply thing to do

first start by defining some css

Code: Select all
.newsDivs
{
    display: none;
}
then a small script in the top of your document

Code: Select all
var currentNews = false; // will hold reference to last opened news item so it can be closed for a new one

function toggleNews (id) // function takes an element id that will be toggled
{
       var newsItem = document.getElementById (id);
       // close the old news item if there is one
       if (currentNews)
           currentNews.style.display = 'none';
        
       // now display the new div
           newsItem.style.display = 'block';
       // store it as current item
           currentItem = newsItem;
}
Okay so that's your javascript, now all you need to do is put the news content into divs in your html and give them the class "newsDivs" and a unique id. Then on the links that you want to toggle the displays, put onmouseover="toggleNews('divId')";

EG

HTML: Select all
<a href="#" onmouseover="toggleNews('div1')">Show div1</a>
<a href="#" onmouseover="toggleNews('div2')">Show div2</a>

<div class="newsDivs" id="div1"> Hello, I am some random content created by rakuli to show this script</div>
<div class="newsDivs" id="div2">No! <em>I</em> am the aforementioned random content</div>
That should sort ya out
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 8th, 2007, 16:47
WDH WDH is offline
Junior Member
Join Date: Aug 2007
Location: UK
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Re: mouseover - news headlines

Cheers, So top code goes in .css 2nd code goes at the top of my html document and the last is the usual page code where i want it?
I will give it a try now.

edit **
Ive tried out your code but i cant get it to work on my site. Whenever the code is placed at the otp of the html doucument it appears as text on the site and isnt hidden. Would you be able to help?

Last edited by Rakuli; Dec 10th, 2007 at 05:17. Reason: added PM question
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Dec 8th, 2007, 16:52
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: mouseover - news headlines

Quote:
--------------------------------------------------------------------------------

Cheers, So top code goes in .css 2nd code goes at the top of my html document and the last is the usual page code where i want it?
I will give it a try now.
yup that's right
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Dec 10th, 2007, 05:18
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: mouseover - news headlines

Quote:
Ive tried out your code but i cant get it to work on my site. Whenever the code is placed at the otp of the html doucument it appears as text on the site and isnt hidden. Would you be able to help?
You need to make sure your CSS is set up correctly and that each div inherits the .newsDivs class. In doing so it will ensure that the default display for the divs is none
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with JS mouseover/popup stevemtno JavaScript Forum 9 May 8th, 2008 15:50
Mouseover buttons help! JIM_genius5 Web Page Design 4 Jan 24th, 2008 16:30
Image link mouseover QUIRK fuzzee Web Page Design 3 Jun 14th, 2007 15:08
How to make flash news headlines marcusharun Flash & Multimedia Forum 7 Oct 30th, 2006 21:15
News Ticker Headlines Keep Rolling zymurgy JavaScript Forum 0 May 19th, 2006 14:03


All times are GMT. The time now is 01:57.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42