absentx
absentx

Reputation: 1427

Strange IE7 quirk

I am getting the following error in IE9 when in IE7 mode. Using a small counting script:

SCRIPT1028: Expected identifier, string or number

Code

$.fn.countTo.defaults = {
    from: 0,  // the number the element should start at
    to: 100,  // the number the element should end at
    speed: 1000,  // how long it should take to count between the target numbers
    refreshInterval: 100,  // how often the element should be updated
    decimals: 2,  // the number of decimal places to show
    onUpdate: null,  // callback method for every time the element is updated,
    onComplete: null,  // callback method for when the element finishes updating
};

Line 185 is the last curly bracket and semi colon

We need this to work in IE7 but this error is breaking the script.

Upvotes: 0

Views: 213

Answers (3)

Xenology
Xenology

Reputation: 2462

The issue is with the last comma on the final value of your defaults. IE has an issue with this. make it like this and you should be good:

$.fn.countTo.defaults = {
    from: 0,  // the number the element should start at
    to: 100,  // the number the element should end at
    speed: 1000,  // how long it should take to count between the target numbers
    refreshInterval: 100,  // how often the element should be updated
    decimals: 2,  // the number of decimal places to show
    onUpdate: null,  // callback method for every time the element is updated,
    onComplete: null  // callback method for when the element finishes updating
};

Upvotes: 2

ahren
ahren

Reputation: 16959

$.fn.countTo.defaults = {
   from: 0,  // the number the element should start at
   to: 100,  // the number the element should end at
   speed: 1000,  // how long it should take to count between the target numbers
   refreshInterval: 100,  // how often the element should be updated
   decimals: 2,  // the number of decimal places to show
   onUpdate: null,  // callback method for every time the element is updated,
   onComplete: null  // callback method for when the element finishes updating
};

Remove the comma after onComplete: null

Upvotes: 5

Dave Newton
Dave Newton

Reputation: 160321

Remove the trailing comma after onComplete.

Upvotes: 8

Related Questions