IE9在jquery点击事件后崩溃

时间:2012-06-26 18:21:28

标签: jquery html internet-explorer-9

我遇到一个奇怪的问题,IE9会在发生点击事件时崩溃。我认为这是克隆功能可能是一个错误,所以尝试删除它但同样的问题。它适用于所有浏览器,即使是IE7和8,但9只是不断崩溃而且不确定。

    <div class="icons">
        <span class="attMessage"></span>
        <span class="successMessage"></span>
        <span class="errorMessage"></span>
    </div>

    <div class="newSection">
        <h3>Add/Update Adjuster License</h3>
        <p>(this is where i am appending an icon from above)</p>
        <p><a title="Add license to queue" class="addLicense"></a></p>  
    </div>

_

    $('.addLicense').click(function () {
      var parent = $(this).parent();
      var license = $('.licenseOverview');
      var dropdown = $('#MainContent_ddlLicenseStates').val();
      var number = $('#MainContent_txtLicenseNumber').val();
      if (number != '') {            
        notifier(parent, "License Added To Queue", "Success");
        $('#MainContent_txtLicenseNumber').val('');
      }
      else {
        notifier(parent, "Must Enter A License Number", "Failure");
      }
    });

    function notifier(oAppend, oMessage, oMessageType) {
      var iconDiv = $('.icons');
      if (oMessageType == 'Success') {
      $('.icons > .successMessage').clone().html(oMessage).appendTo(oAppend).delay(100).fadeIn('slow').delay(500).fadeOut();
      //tried a different way since i thought clone was crashing ie9        
      //$('.icons > .successMessage').html(oMessage).appendTo(oAppend).delay(100).fadeIn('slow').delay(500).fadeOut();
      setTimeout(function () {    oAppend.find('.successMessage').remove().appendTo(iconDiv); }, 2500);
      }
      else if (oMessageType == 'Failure') {
      $('.icons > .errorMessage').clone().html(oMessage).appendTo(oAppend).delay(100).fadeIn('slow').delay(500).fadeOut();
      setTimeout(function () { oAppend.find('.errorMessage').remove() }, 2500);

      }
      else if (oMessageType == 'Warning') {
      $('.icons > .attMessage').clone().html(oMessage).appendTo(oAppend).delay(100).fadeIn('slow').delay(500).fadeOut();
      setTimeout(function () { oAppend.find('.attMessage').remove() }, 2500);

      }
    }

1 个答案:

答案 0 :(得分:0)

看起来像是fadeIn()。延迟(500).fadeOut()是罪魁祸首。一旦fadeOut发生IE9崩溃。我删除了fadeOut并且没有发生崩溃。而不是使用延迟我使用超时功能来处理fadeOut而不再崩溃。

    $('.icons > .successMessage').clone().html(oMessage).appendTo(oAppend).delay(100).fadeIn('slow');
    setTimeout(function () { oAppend.find('.successMessage').fadeOut().remove(); }, 2500);