www.webdeveloper.com
Results 1 to 2 of 2

Thread: JavaScript errors in IE - expected ';' & 'position().left' is null

Hybrid View

  1. #1
    Join Date
    Sep 2013
    Posts
    12

    JavaScript errors in IE - expected ';' & 'position().left' is null

    I got two errors in IE I think it might be number 8 version.

    These are the errors, I would appreciate if someone can help me. I'm getting confused with the script.

    First error

    Message: Expected ';' Line: 57 Char: 9 Code: 0 ----this is the line 57 referring to "jquery-1.3.1.min.js" call script which is located in the index.html

    Second error

    Message: 'position().left' is null or not an object Line: 44 Char: 5 Code: 0 which is this Line 44 - which is located within the script:

    $magicLineTwo

    this is how the script looks like, there are two sets for this and the second one is making the problem:

    EXAMPLE ONE
    */
    $mainNav.append("<li id='magic-line'></li>");

    var $magicLine = $("#magic-line");

    $magicLine
    .width($(".current_page_item").width())
    .css("left", $(".current_page_item a").position().left)
    .data("origLeft", $magicLine.position().left)
    .data("origWidth", $magicLine.width());

    $("#example-one li").find("a").hover(function() {
    $el = $(this);
    leftPos = $el.position().left;
    newWidth = $el.parent().width();

    $magicLine.stop().animate({
    left: leftPos,
    width: newWidth
    });
    }, function() {
    $magicLine.stop().animate({
    left: $magicLine.data("origLeft"),
    width: $magicLine.data("origWidth")
    });
    });


    /*
    EXAMPLE TWO
    */
    $mainNav2.append("<li id='magic-line-two'></li>");

    var $magicLineTwo = $("#magic-line-two");

    $magicLineTwo
    .width($(".current_page_item_two").width())
    .height($mainNav2.height())
    .css("left", $(".current_page_item_two a").position().left)
    .data("origLeft", $(".current_page_item_two a").position().left)
    .data("origWidth", $magicLineTwo.width())
    .data("origColor", $(".current_page_item_two a").attr("rel"));

    $("#example-two li").find("a").hover(function() {
    $el = $(this);
    leftPos = $el.position().left;
    newWidth = $el.parent().width();
    $magicLineTwo.stop().animate({
    left: leftPos,
    width: newWidth,
    backgroundColor: $el.attr("rel")
    })
    }, function() {
    $magicLineTwo.stop().animate({
    left: $magicLineTwo.data("origLeft"),
    width: $magicLineTwo.data("origWidth"),
    backgroundColor: $magicLineTwo.data("origColor")
    });
    });
    });

    what could possibly go wrong for the IE to mark the "example two" as an "error" and have no problems with example one? The script (is a draggable little icon used for the menu bar, the effect is every time the mouse is moved on each option in the menu there's a little dot that follows.

  2. #2
    Join Date
    Sep 2013
    Posts
    12
    this is the link http://jsfiddle.net/ghAkB/4/ I want to keep the same effect of the line moving when the options of the menu are on hover but remove this error that is killing me if I cant get rid of them I will never finish a website that has been going on for more than a month

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