www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Object Required, Code 0... why?

  1. #1
    Join Date
    Feb 2003
    Posts
    102

    resolved [RESOLVED] Object Required, Code 0... why?

    Hi all,

    I have a script that I have been modifying to allow for multiple expandable and collapsable divs.

    It works fine in both IE8 and Firefox 3.6. The only problem is that in IE8, the "Expand All" link generates a javascript error down towards the bottom-left of the window that when opened indicates an error of Object Required, Code 0.

    The page which includes both HTML and Javascript can be found here:
    http://www.cityscope.com.au/test/test2.html

    If using IE8 you can see the line number on which it suggests (possibly incorrectly) there is an error.

    From previous searches on this site for similar posts it sounds like it could be an issue with the way I'm referring to DIVs. I have tried many varations to no avail.

    Can anyone offer any suggestions? It would be nice if I could get rid of this one!

    Thanks!


    Chris
    Officially confused.

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,258

    Arrow

    You're assignments are too big for the expand/shrink command.

    Use:
    Code:
    <p align="center"><a href="javascript:expand_all(2);">Expand All</a>
     / <a href="javascript:shrink_all(2);">Shrink All</a></p>
    and you have an assignment problem.
    Code:
    		var elm_short = document.getElementById('item_' + i + '_short').style.display = "none";
    		var elm_long = document.getElementById('item_' + i + '_long').style.display = "inline";
    		var elm_linkshort = document.getElementById('item_' + i + '_linkshort').style.display = "none";
    		var elm_linklong = document.getElementById('item_' + i + '_linklong').style.display = "inline";
    You don't need the var assignment in the shrink_all and expand_all functions.

  3. #3
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by Chris Jacks View Post
    Hi all,

    I have a script that I have been modifying to allow for multiple expandable and collapsable divs.

    It works fine in both IE8 and Firefox 3.6. The only problem is that in IE8, the "Expand All" link generates a javascript error down towards the bottom-left of the window that when opened indicates an error of Object Required, Code 0.
    That error exists in all browsers.
    You're specifying a number range of 4, thereby addressing non-existent elements.
    Try to come up with a more maintainable system.
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  4. #4
    Join Date
    Feb 2003
    Posts
    102
    Well, that's made me feel incredibly silly!

    I severe case of having one's mind elsewhere and not being able to see the most simple and obvious solutions to a problem.

    Logic Ali, JMRKER, thanks very much for the prompt replies!

    I completely forgot (and failed to notice) that I had put the "forced" count in there from another test. I have replaced with my counter again, which I believe addresses your comments JMRKER re more maintainable.

    A great example for future posters... if you know you're not focussed. Just wait until your mind has cleared then look again!
    Officially confused.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles