2012-05-29 4 views
0

Я получаю следующую ошибку в IE9, когда в IE7 режиме. С помощью небольшой счетный скрипт:Странный IE7 quirk

SCRIPT1028: Ожидаемый идентификатор, строка или номер

Код

$.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 является последней фигурные скобки и с запятой

Нам нужно это для работы в IE7, но эта ошибка нарушает сценарий.

+2

Я действительно предлагаю не использовать режим совместимости браузеров для тестирования IE. Эти режимы почти, но не совсем, в отличие от их реальных счетных частей. Вот ссылка на виртуальные ПК Microsoft для тестирования нескольких версий IE: http://www.microsoft.com/en-us/download/details.aspx?id=11575 – JaredMcAteer

+0

+1 к комментарию JaredMcAteer. Плюс из трех слов в заголовке сообщения два являются избыточными. –

+0

Возможный дубликат [Ожидаемый идентификатор или строка в javascript] (http://stackoverflow.com/questions/4930960/expected-identifier-or-string-in-javascript) Это был главный результат при вводе сообщения об ошибке в поиск коробка. http://stackoverflow.com/search?q=Expected+identifier%2C+string+or+number –

ответ

8

Снять задние запятые после onComplete.

+0

отлично, спасибо много – absentx

5
$.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 
}; 

Удалить запятую после onComplete: null

2

вопроса с последней запятой на конечном значении параметров по умолчанию. У IE есть проблема с этим. сделайте это так, и вы должны быть хорошими:

$.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 
}; 
Смежные вопросы