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
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't figure out Javascript Error in IE, works in Firefox

    Hi all and thanks,

    I get the following error in my coding: I'm not sure if this means I have to declare this as a variable. It works fine in Firefox, but not in IE. Any suggestions or can anyone point me in the right direction? Thanks a bunch.

    Line: 268

    Error 'offsetParent.offsetLeft' is null or not an object
    Code: 0

    Here is the function

    function hideElement( elmID, overDiv ) {
    if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
    obj = document.all.tags( elmID )[i];
    if(!obj || !obj.offsetParent) continue;
    // Find the element's offsetTop and offsetLeft relative to the BODY tag.
    LINE 268: objLeft = obj.offsetLeft - overDiv.offsetParent.offsetLeft;
    objTop = obj.offsetTop;
    objParent = obj.offsetParent;
    while(objParent.tagName.toUpperCase() != 'BODY') {
    objLeft += objParent.offsetLeft;
    objTop += objParent.offsetTop;
    objParent = objParent.offsetParent;}
    objHeight = obj.offsetHeight;
    objWidth = obj.offsetWidth;
    if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
    else if((overDiv.offsetParent.offsetTop + overDiv.offsetHeight + 20) <= objTop);
    else if(overDiv.offsetParent.offsetTop >= eval(objTop + objHeight));
    else if(overDiv.offsetLeft >= eval(objLeft + objWidth));
    else {
    obj.style.visibility = 'hidden';
    }

    }
    }
    }

  • #2
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bradwbowman View Post
    Hi all and thanks,

    I get the following error in my coding: I'm not sure if this means I have to declare this as a variable. It works fine in Firefox, but not in IE. Any suggestions or can anyone point me in the right direction? Thanks a bunch.

    Line: 268

    Error 'offsetParent.offsetLeft' is null or not an object
    Code: 0

    Here is the function

    function hideElement( elmID, overDiv ) {
    if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
    obj = document.all.tags( elmID )[i];
    if(!obj || !obj.offsetParent) continue;
    // Find the element's offsetTop and offsetLeft relative to the BODY tag.
    LINE 268: objLeft = obj.offsetLeft - overDiv.offsetParent.offsetLeft;
    objTop = obj.offsetTop;
    objParent = obj.offsetParent;
    while(objParent.tagName.toUpperCase() != 'BODY') {
    objLeft += objParent.offsetLeft;
    objTop += objParent.offsetTop;
    objParent = objParent.offsetParent;}
    objHeight = obj.offsetHeight;
    objWidth = obj.offsetWidth;
    if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
    else if((overDiv.offsetParent.offsetTop + overDiv.offsetHeight + 20) <= objTop);
    else if(overDiv.offsetParent.offsetTop >= eval(objTop + objHeight));
    else if(overDiv.offsetLeft >= eval(objLeft + objWidth));
    else {
    obj.style.visibility = 'hidden';
    }

    }
    }
    }

    I believe is the smilie face in your code that is causing the problem..



    Try adding a conditional statement that makes sure offsetParent.offsetLeft is an object.

    Code:
    if (typeof(offsetParent.offsetLeft) == 'object') { // do stufff }
    document.all - that looks a bit archaic..
    Fiji Web Design - where i do Joomla Web Design
    Bucabay.com - My blog

  • #3
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by digital-ether View Post
    I believe is the smilie face in your code that is causing the problem..
    Fwiw, that's being thrown in by the CodingForums post parser as it encounter the :) character combination and won't be part of their original code.
    This can be prevented by selecting Disable smilies in text in the Additional Options on post form pages.

  • #4
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Bill Posters View Post
    Fwiw, that's being thrown in by the CodingForums post parser as it encounter the character combination and won't be part of their original code.
    This can be prevented by selecting Disable smilies in text in the Additional Options on post form pages.
    Sorry, that was meant to be a joke.

    I also made an error in my suggestion, it should have been:

    Code:
    if (typeof(offsetParent) == 'object') { // do stufff }
    You should make sure the offsetParent is an 'object' (As all HTMLElements are). Then try to access a property.
    Fiji Web Design - where i do Joomla Web Design
    Bucabay.com - My blog


  •  

    Posting Permissions

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