Stop reloading flash file when using show and hide methods

前端 未结 4 1159
无人及你
无人及你 2020-12-19 09:01

I have a web page where a flash file is embeded in that.The flash file is having a quiz consist of 4 questions.When user answer the first question the second question will b

4条回答
  •  盖世英雄少女心
    2020-12-19 09:11

    The internal $.hide() method does a css: display:none; on your element. This will cause the flash to reload each time. I would suggest hiding your flash a different way, since it reacts poorly to this css property.

    Here is a plugin that hides your element by positioning it off of the screen. This doesn't work in all cases, but can be very useful if it applies to you.

    The CSS to add:

    .flashHide {
      position:absolute;
      left:-99999px;
    }
    

    And the plugin to add:

    (function($){ 
      var hideClassName = 'flashHide'; 
      $.fn.extend({ 
        flashHide: function() { 
          return this.each(function(){ 
            $(this).addClass(hideClassName); 
          }); 
        }, 
        flashShow: function() { 
          return this.each(function(){ 
            $(this).removeClass(hideClassName); 
          }); 
        } 
      }); 
    })(jQuery);
    

    Then you would use it like this:

    $('div#flashContainer').flashHide();
    $('div#flashContainer').flashShow();
    

提交回复
热议问题