Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old December 8th, 2007, 12:15 PM   #1
WDH
New Member
 

Join Date: Aug 2007
Location: UK
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 WDH is on a distinguished road
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.
WDH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 8th, 2007, 12:41 PM   #2
Highly Reputable Member
SuperMember
 
Rakuli's Avatar
 

Join Date: Sep 2007
Location: Australia
Age: 25
Posts: 954
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold
Re: mouseover - news headlines

Well this is a reasonably simply thing to do

first start by defining some css

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

Code:
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 Code:
<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
__________________
Luke Dingle . com
Rakuli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 8th, 2007, 12:47 PM   #3
WDH
New Member
 

Join Date: Aug 2007
Location: UK
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 WDH is on a distinguished road
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; December 10th, 2007 at 01:17 AM.. Reason: added PM question
WDH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 8th, 2007, 12:52 PM   #4
Highly Reputable Member
SuperMember
 
Rakuli's Avatar
 

Join Date: Sep 2007
Location: Australia
Age: 25
Posts: 954
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold
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
__________________
Luke Dingle . com
Rakuli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 10th, 2007, 01:18 AM   #5
Highly Reputable Member
SuperMember
 
Rakuli's Avatar
 

Join Date: Sep 2007
Location: Australia
Age: 25
Posts: 954
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold
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
__________________
Luke Dingle . com
Rakuli is offline  
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

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 9 May 8th, 2008 11:50 AM
Mouseover buttons help! JIM_genius5 HTML, XHTML and CSS 4 January 24th, 2008 12:30 PM
Image link mouseover QUIRK fuzzee HTML, XHTML and CSS 3 June 14th, 2007 11:08 AM
How to make flash news headlines marcusharun Flash and ActionScript 7 October 30th, 2006 05:15 PM
News Ticker Headlines Keep Rolling zymurgy JavaScript 0 May 19th, 2006 10:03 AM


Search Engine Optimization by vBSEO 3.2.0 RC8