3

I have a problem in IE8:

function costructor(sectionId){
$('#nextG').ready(function(){
var counterBis = 0;
slider = '.slider0'+sectionId;
//sliderBox = $(slider).closest('.floatContent');
unitScrollBis = $(slider).find('.floatImg').eq(0).width();
maxImg = $(slider).find('.floatImg').length-2;
    /*problem*/
prev = "#" + $("#controller0" + sectionId).find(".controller").eq(0).attr("id");
next = "#" + $("#controller0" + sectionId).find(".controller").eq(0).attr("id");
    /*END*/
console.log(prev);
console.log(next);
makeMove(counterBis,unitScrollBis,prev,next,slider,maxImg);
function makeMove(counterBis,unitScrollBis,prev,next,slider,maxImg){
if(counterBis <= 0){
    $(prev).fadeOut("fast");
}
else if(counterBis >= maxImg){
    $(next).fadeOut("fast");
}
$(next).click(function(){
    if(counterBis <= maxImg){
        counterBis++;
        $(prev).fadeIn("fast");
        slide(counterBis);
        }
    else{
        $(next).fadeOut("fast");
    }
});
$(prev).click(function(){
    if(counterBis > 0){
        counterBis--;
        $(next).fadeIn("fast");
        slide(counterBis);
    }
    else{
        $(prev).fadeOut("fast");
    }
});
function slide(counterBis){
    $(slider).animate({
    marginLeft: '-' + (unitScrollBis*counterBis) + 'px'
},1000);
};
};

IE8 says that: SCRIPT438: Object doesn't support property or method Can anyone help me? The problem is only in IE8, I don't understand why IE can't build this string. thanks for the help

0

1 Answer 1

3

You need to declare variables with the var keyword, otherwise older versions of IE will not recognise them and possibly break.

So change

prev = "#" + $("#controller0" + sectionId).find(".controller").eq(0).attr("id");
next = "#" + $("#controller0" + sectionId).find(".controller").eq(0).attr("id");

to

var prev = "#" + $("#controller0" + sectionId).find(".controller").eq(0).attr("id");
var next = "#" + $("#controller0" + sectionId).find(".controller").eq(0).attr("id");

and everything should work as it does in other browsers/IE9

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

9 Comments

thank's problem solved, ie>8 don't have this problem, and the othe browser too.I have a question to you:'why some developers not use the keyword var for some variables?'
@user1856813 Yeah sorry I meant to mention it's like an IE8-and-before issue, IE9+ and others are fine without it thankfully.
In regard to your question, check out this question and it's answers - stackoverflow.com/questions/1470488/…
I have a question to you:'why some developers not use the keyword var for some variables?'
@ghost Because unfortunately for the smart developers, someone wrote "w3schools", teaching all the new programmers horrendous coding practices such as global variables, using keywords as variable names, blah blah blah...
|

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.