使用show和hide方法时停止重新加载flash文件 [英] Stop reloading flash file when using show and hide methods

查看:182
本文介绍了使用show和hide方法时停止重新加载flash文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Flash文件嵌入在其中的网页。闪存文件有一个由4个问题组成的测验。当用户回答第一个问题时,第二个问题将被显示。这个Flash被嵌入在一个叫做div divFlashcontent.Now我想隐藏和显示测验inbetween.Ex:当用户点击一个按钮(暂停),我想隐藏测验。当他点击继续按钮时,我想继续(显示)测验。我正在使用jquery show()方法并隐藏此方法。但问题是,当我调用显示方法的Flash内容被再次加载(显示从一开始的测验)。它不显示我们点击暂停buttton的阶段。我如何解决这个问题?我想让flash处于隐藏状态。

解决方案内部 $。hide( )方法在元素上执行css: display:none; 。这将导致闪光每次重新加载。我建议以不同的方式隐藏你的Flash,因为它对这个CSS属性反应不佳。



这是一个插件,通过将它放置在屏幕之外来隐藏你的元素。这在所有情况下都不起作用,但如果适用于您,它可能会非常有用。



要添加的CSS:

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

和插件添加:

 (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);

然后你可以像这样使用它:

  $( 'DIV#flashContainer')flashHide(); 
$('div#flashContainer')。flashShow();


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 be shown.This flash is embeded in a div called divFlashcontent.Now i want to hide and show the quiz inbetween.Ex: When the user clicks a button("Pause"), i want to hide quiz. and when he clicks "Continue" button, i want to continue (show ) the quiz. I am using jquery show() method and hide method for this. But the problem is ,When i call the show method the flash content is being loaded again(Showing the quiz from the start).It is not showing the stage where we clicked the pause buttton. How can i solve this ? I want flash to be in the same stage where its become hidden

解决方案

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();

这篇关于使用show和hide方法时停止重新加载flash文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆