Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Menubar Error 'lastChild' is null or not an object

    Hey Guys,

    I wondered if anyone would be kind enough to look at an issue I am having running a Javascript on IE.

    The script works fine in FF and Chrome but chucks up an error in all versions of IE so the Menubar does not display child pages.

    Here's the Error:

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Timestamp: Tue, 16 Aug 2011 14:45:53 UTC

    Message: 'lastChild' is null or not an object
    Line: 31
    Char: 3
    Code: 0

    The full script is here: http://www.makingtrails.com/wp-conte...ks3/js/menu.js

    Any help much appreciated as the author of this script is not providing any support.

    Thanks

    Jon

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Debug time?

    For starters, I'd do alert(this.body.lastChild) just before the problem line. See if indeed that gives null or gives an [Object] (I think that's what MSIE would show).

    If it shows [Object] then apparently the cleanWhitespace is doing something nasty to this.body.

    If it shows null then apparently MSIE doesn't see that this.body has a lastChild. Which begs the question as to just what MSIE thinks this.body refers to. For that matter, maybe doing alert(this.body.firstChild) might reveal something.

    If you want more help, though, I think you need to show us the problem in a live page.
    Last edited by Old Pedant; 08-18-2011 at 03:04 AM.

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your reply.

    I tried alert(this.body.lastChild) but showed as null

    Debugged in IE9 and got a slighty different notification.

    Unable to get value of the property 'getElementsByTagName': object is null or undefined

    cleanWhitespace(this.body).lastChild.getElementsByTagName('a')[0].className += ' last';

    This error is occurring while attempting to load the navigation menu on http://www.makingtrails.com

    Thanks

  • #4
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The menu is working in IE under http://testing.makingtrails.com

    Same script though, maybe now it's a conflict.


  •  

    Posting Permissions

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