0

FireFox 3.6で、jQuery(v1.7.2)内で非jQuery関数を呼び出すのが気に入らないという問題があります。

私のコードのバージョンを削減します:

function doInitialiseForm( theField ) {
  /* loop through a few fields and set the appropriate attributes & class */
  nX = parseInt( theField ) ;
  var inputElement = '' ;
  for ( i=(nX + 1); i <= 10 ; i++ )
  {
    $('#acBox' + i).addClass('pHide') ;  
    /* toggle the required attribute/class on the input boxes - for HTML5 input validation to behave correctly ... */
    inputElement =  document.getElementById('acBoxName_' + i ) ;
    inputElement.removeAttribute('required');
    $( inputElement ).removeClass( 'required' )
  }
}

$(document).ready(function() {

  if ( isBookingPage == '1' )
  {
      doInitialiseForm( document.getElementById('AttendingCount') ) ;  
  }
});

FireFoxが報告しているエラー:

Error: uncaught exception: [Exception... "Not enough arguments"  nsresult: "0x80570001   (NS_ERROR_XPC_NOT_ENOUGH_ARGS)"  location: "JS frame :: http//development_server/Booking/js/script.js :: doInitialiseForm:: line 65"  data: no]

これは、FFがthingyの3番目のパラメーターを期待していることに関連しているようremoveEventListener()です。これはオプションです。しかし、私は直接使用していませんremoveEventListener()

上記のコードを古いバージョンのFireFoxで機能させるには、どのような追加のコードを実装する必要がありますか?

4

1 に答える 1

0

問題は解決しました。

関数 doInitialiseForm() から省略されたコードの一部が setAttribute() を呼び出していたため、2 番目のパラメーターを含めませんでした。

つまり、もともと次のように書かれています

inputElement.setAttribute('required');

いつあるべきか

inputElement.setAttribute('required','');
于 2012-07-18T08:43:02.473 に答える