473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

onclick code not working. Browser's error: object expected lines 11, 12, 13

18
I could about swear this was working perfectly while I was adding some other functionality somewhere else. I now removed that functionality and it doesn't work. If someone could find what I broke, please tell me. I am new to using JavaScript seriously (probably been tweaking individual lines of code for 5 years) and after staring at my mistake for hours I probably can no longer see it.

Intended functionality: 3 links that can be clicked to display a different div tag.

I'm testing with Win XP Prof SP2, IE7, English. Later I'll be on a PC that has a slew of other browsers loaded, but I think it's my own ignorance--not IE7's.

HTML:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>URL.NET</title>
  4. <link rel="stylesheet" type="text/css" href="homestyle.css" />
  5. <script src="section.js"></script>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <div id="menuWrapper">
  11.     <div id="home" class="menuButton" onclick="activateSection('home');">Home</div><div class="menuSpacer"></div>
  12.     <div id="visitme" class="menuButton" onclick="activateSection('visitme');">Visit Me!</div><div class="menuSpacer"></div>
  13.     <div id="contactme" class="menuButton" onclick="activateSection('contactme');">Contact Me</div>
  14. </div>
  15.  
  16. <div id="contentWrapper">
  17.     <div id="homeTab" class="tabContent">Go Home</div> 
  18.     <div id="visitmeTab" class="tabContent">Visit Me</div> 
  19.     <div id="contactmeTab" class="tabContent">Contact Me: <a href="mailto:me@gmail.com">me@gmail.com</a></div>
  20.     <div id="errorTab" class="tabContent">Something Isn't working.</div>
  21. </div>
  22.  
  23. </body>
  24. </html>
  25.  
my script:
Expand|Select|Wrap|Line Numbers
  1. function activateSection(section)
  2. {
  3.     var home = document.getElementById("homeTab");
  4.     var visitme = document.getElementById("visitmeTab");
  5.     var contactme = document.getElementById("contactmeTab");
  6.     var error = document.getElementById("errorTab");
  7.  
  8.     if (section == 'home') 
  9.     {
  10.         home.style.display="block";
  11.         visitme.style.display="none";
  12.         contactme.style.display="none";
  13.         error.style.display="none";
  14.     }
  15.     else if (section == 'visitme') 
  16.     {
  17.         home.style.display="none";
  18.         visitme.style.display="block";
  19.         contactme.style.display="none";
  20.         error.style.display="none";
  21.     else if (section == 'contactme') 
  22.     {
  23.         home.style.display="none";
  24.         visitme.style.display="none";
  25.         contactme.style.display="block";
  26.         error.style.display="none";
  27.     }
  28.     else
  29.     {
  30.         home.style.display="none";
  31.         visitme.style.display="none";
  32.         contactme.style.display="none";
  33.         error.style.display="block";
  34.     }
  35. }
  36.  
I don't think you need to see my CSS, but it should be CSS2 standards-compliant and includes an htc fix for explorer to make IE 5 through 7 do what it should do with hover pseudo-classes if IE where standards compliant.

Many thanks!
Sep 25 '07 #1
3 8385
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

On the third 'else' between lines 20 and 21, you have a closing bracket missing.
Sep 25 '07 #2
Danigan
18
I would donate my life to the hatred of bracket and semi-colon related errors but... I did that many years ago when I learned my first language.

Many thanks indeed. I will frequent these forums so that I may learn and give back the time and knowledge I take.
Sep 25 '07 #3
acoder
16,027 Expert Mod 8TB
Glad to hear you got it working. A good idea would be to check the error console of a browser that gives you better error messages.
Sep 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
0
by: malcolm | last post by:
How do I get a web-browser loaded with on-the-fly content and a JavaScript onclick popup function to work? I've embedded an axWebBrowser in my (vb.net) application. The browser starts with...
4
by: Roland | last post by:
I was wondering, what happens when you have an onclick event and an error occurs in it: In an <a> element: onclick="zoomFullExtent(); return false;" I know that there is an error happening...
53
by: usenet | last post by:
See <ul> <li><a name="link1" onClick="alert(this.name);return false;" href="#">Link1</a></li> <li><a name="link2" href="javascript:alert(this);">Link2</a></li> <li>Item 3</li> </ul> ...
5
by: moondaddy | last post by:
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and perhaps other browsers for all I know...). Below...
5
by: Joe Simmonds | last post by:
Hi All, I have just had a problem with some VB.net, I wonder if anybody can shed a little light and ease my confused brain. The problem is resolved now but I can't work out what happened and,...
5
by: Fred.Grieco | last post by:
Hi every body, I have a little pb and I'm turning around : function MyFCTN(var1,var2) { var mytable = document.getElementById("myTBL"); for (var i=myTBL.childNodes.length-1; i>0; i--){...
4
by: phil | last post by:
Hi, I defined a Html button but added the option 'runat="server" ' like this: <form id="form1" runat="server"> <input id="Button1" type="button" value="button" runat="server" onclick="hfd()" ...
17
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/this-alert.html http://www.frostjedi.com/terra/scripts/demo/this-alert2.html Why, when you click in the black box, do the alert boxes say different...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.