3

I am getting an error only on IE9 that the error says "SCRIPT5007: Object expected". There are 2 same error. One is at $(document) at beggining and another is marked as "<- error here"

    <script>
        $(document).ready(function(){
            var imagePath = "/sites/all/modules/custom/sixdegrees_right_menu/images/";
            $(".menu-holder").mouseover(function()
            {
                //$(this).children(".menu-title").children(".menu-bg").hide();
                //$(this).children(".menu-title").children(".menu-name").css({"float":"none"});
                //$(this).children(".menu-title").children(".menu-text").css({"float":"none"});

                var imgSrc = $(this).children(".menu-icon").find("img").attr("src");
                imgSrc = imgSrc.replace(imagePath, "");
                imgSrc = imagePath + "h-" + imgSrc;
                $(this).children(".menu-icon").find("img").attr("src", imgSrc);
                <- error here
                //$(this).children(".menu-title").children(".menu-name").children("img").animate({"left": "0px"}, "slow");
                //$(this).children(".menu-title").children(".menu-text").animate({"left": "0px"}, "slow");
            });
        });
    </script>

There also have some commented lines which I don't have enough permission to delete it unless I can claim something.

2
  • can you post the related HTML? Commented Mar 8, 2012 at 4:35
  • use whatever instance of 'find and replace' you have in your IDE, search for $ and replace with jQuery. I'm just going to guess you probably have some MVC Framework or something installed. Commented Mar 8, 2012 at 5:15

1 Answer 1

2

add a type="text/javascript" to your script tag, and make sure you are successfully including jQuery before attempting to use it.

Sign up to request clarification or add additional context in comments.

5 Comments

+1 for the type. but if you don't include jQuery beforehand, the error would be something like "$ not defined"
While the type attribute is required for valid HTML, in practice it isn't necessary (and hasn't been for a very long time) unless some other script language has already been used in the page. In any case, if jQuery hasn't been included then unless some other script has defined a value for $ then an error will be thrown at the very first $ and that will be that, it will never reach the "error here" line.
@Joseph—in IE the error is "Object expected" as reported by the OP.
both correct, just grasping at straws as i am not familiar with IE9's javascript interpreter :)
Some thing is magical here. I found this error at live server and also at our staging server. But at the evening it gone away from both server. I didn't change a bit of code. See at live server - sixdegrees.org on right side menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.