homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Load Page show one div hide others
My code allows links to toggle divs but initially loads them all

Msg#: 4203996 posted 11:26 pm on Sep 19, 2010 (gmt 0)

Adapting a code that I found on your forum here:


I was able to successfully create a series of links that allow one div at a time to appear on the page. However, when the page loads, all of the divs show up.

I tried creating a new function and calling it with body.onload

function justRecipe() {
document.getElementById('Recipe').style.display = 'block';
document.getElementById('Shopping').style.display = 'none';
document.getElementById('TableTopics').style.display = 'none';
document.getElementById('QualityTime').style.display = 'none';
document.getElementById('Newsletter').style.display = 'none';

<body.onload = justRecipe()>

No luck!

Here is the link to see the code in action:


Help is greatly appreciated.


Jean Fisher
What's For Dinner?
Make dinner time, family time!



10+ Year Member

Msg#: 4203996 posted 8:43 am on Sep 20, 2010 (gmt 0)

Welcome to the Webmasterworld.

It should be <body onload="justRecipe();">, without a dot, and with a proper markup.


Msg#: 4203996 posted 1:11 pm on Sep 20, 2010 (gmt 0)

Thank you, alias. Everything works perfectly.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved