2016-11-04 1 views
0

なぜIE上でコードがエラーを報告するのか分かりません。ここでは、コードは次のようになります。if文にIEがスローされる

if ($size === null) { 
    $sizeFolder = '48x48'; 
} else $sizeFolder = $size+'x'+$size; 

次のようにエラーがある:

if ($size === null)) { 
    $sizeFolder = '48x48'; 
} else $sizeFolder = $size+'x'+$size; 

が、これはまだ機能していません。

SCRIPTING1006: ')' expected 

IEはこのように、ここで)を設定します。 IEがエラーを報告するのはなぜですか?

$.ttMessageBox.getIcon = function ($icon,$size=null) { 
    var $_icons = Array('[Information]','[Error]','[Question]','[OK]'); 
    if ($size === null) { 
    $sizeFolder = '48x48'; 
    } else $sizeFolder = $size+'x'+$size; 
    $result = ''; 
    $Icon = $_icons.indexOf($icon); 
    switch ($Icon) { 
    case 0: $result += '<img src="/img/icons/'+$sizeFolder+'/dialog_information.png" />'; 
       break; 
    case 1: $result += '<img src="/img/icons/'+$sizeFolder+'/dialog_error.png" />'; 
       break; 
    case 2: $result += '<img src="/img/icons/'+$sizeFolder+'/dialog_question.png" />'; 
       break; 
    case 3: $result += '<img src="/img/icons/'+$sizeFolder+'/dialog_check.png" />'; 
       break; 
    default: $result += ''; 
    } 
return $result; 
} 
+1

それは、elseステートメントの周りにブラケットを期待することができます。 –

+4

あなたのエラーは、このコードの前のスクリプトのどこかにあります。これは正常に機能し、構文が有効です。スクリプトファイル全体を投稿してください。 – plalx

+0

if($ size === null){'、try - >' if($ size === null){' – Keith

答えて

0

これは現在作業コードです:@Lukeウッドワードへ

$.ttMessageBox.getIcon = function ($icon,$size) { 
    var $_icons = Array('[Information]','[Error]','[Question]','[OK]'); 
    if (typeof $size === "undefined") { 
    $sizeFolder = '48x48'; 
    } else $sizeFolder = $size+'x'+$size; 

おかげ

0

エラーがこの行にある:

$.ttMessageBox.getIcon = function ($icon,$size=null) { 

IEは、関数のパラメータのデフォルト値をサポートしていません

は、ここに完全なコードです。 =nullビットを持つことはできません。

関連する問題