CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Nov 2005
    Location
    Rhode Island, USA
    Posts
    52

    "Object Required" error in IE for javascript that works fine in FF

    The page I am working on has a tabbed interface which works fine using FF but when viewed from IE I receive an "object required" error message at the SetCurrent("Users Table") call.

    My page has FindCurrent() being called at page load which, if it can match the page title up with a specific list it calls a 2nd function which changes the id on a specific list item so that it shows up as "Selected".

    Does anybody have an idea as to what I am doing wrong?

    Code:
           function SetCurrent(title) 
           {
           // Find all list items on the page
           	var oSubjects = document.getElementsByTagName("li");
           	
           	// Cycle through the list items
     		for (var i = 0; i < oSubjects.length; i++)
             {
                var oSubject = oSubjects.item(i);
                var sID = oSubject.getElementsByTagName("span");
                
                // Check the text displayed on them to see if it matches the title passed in
                if ( sID.item(0).innerHTML == title )  {      
           			oSubject.id="current"; // Sets the list item as the "Current" one.
           		}
             }
           }       
           
           function FindCurrent()
           {
           var titleElement = document.getElementsByTagName("title")[0];
           
           // Matching the TITLE of the page up.  If it is found then send in the text displayed on the Tab which is "current"
           if ( titleElement.firstChild.data == "User Table" ) {
           	SetCurrent("Users Table");
           	} else if ( titleElement.firstChild.data == "Table List" ) {
           	SetCurrent("View Tables");
           	} else if ( titleElement.firstChild.data == "Event Table" ) {
           	SetCurrent("Event Table");
           	} else if ( titleElement.firstChild.data == "Inventory Table" ) {
           	SetCurrent("Inventory Table");
           	}
           }
    Last edited by Ryland; June 17th, 2008 at 02:10 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured