SWFUpload文件上传控件之SWFUpload.WINDOW_MODE
最近在使用swfupload控件做上传的功能的时候,发现一个问题,即我将SWFUpload.WINDOW_MODE的值设为WINDOW或者不设定此值的时候,当鼠标经过flash的时候,有视频弹出功能的浏览器会出现视频弹出的提示窗口。
用户点击弹出窗口的时候flash直接在视频的播放窗口显示,原来页面当中的flash文件消失。
尝试将SWFUpload.WINDOW_MODE的值设为OPAQUE或者TRANSPARENT的时候则不会出现此种情况。
SWFUPLOAD官网对这三个属性描述,原文如下:
SWFUpload.WINDOW_MODE
SWFUpload.WINDOW_MODE is a simple object that contains button movie wmode parameter constants. It is used to tell the browser how to display the Flash Movie.
* WINDOW is the default mode. The movie is drawn over the top of all other elements on the page.
* OPAQUE causes the movie to be rendered in the page allowing other elements to cover up the button.
* TRANSPARENT the button background is rendered transparent allowing html elements under the button to show through.
SWFUpload.WINDOW_MODE的值与flash的wmode(窗口模式)的属性值一一对应,即:window、opaque、transparent
我对上面这段描述的理解是,swfupload上传控件在初始化的时候,会在页面插入一个flash实现的button,开发者可以通过SWFUpload.WINDOW_MODE这个常量对象指定这个flash button的wmode参数。SWFUpload.WINDOW_MODE这个常量对象有以下三个值:window是默认值,表示这个flash从页面中抽离出来,位于页面所有其他元素的上层;OPAQUE则表示flash随页面一起渲染,并且页面其他元素可以覆盖其上;TRANSPARENT表示flash的背景在渲染的时候是透明的,其他位于该falsh下方的html 元素仍旧可以显示。
官方对于flash的wmode的三个属性值描述为:
* Window: Use the Window value to play a Flash Player movie in its own rectangular window on a web page. This is the default value for wmode and it works the way the classic Flash Player works. This normally provides the fastest animation performance.
* Opaque: By using the Opaque value you can use JavaScript to move or resize movies that don’t need a transparent background. Opaque mode makes the movie hide everything behind it on the page.
Additionally, opaque mode moves elements behind Flash movies (for example, with dynamic HTML) to prevent them from showing through.
* Transparent: Transparent mode allows the background of the HTML page, or the DHTML layer underneath the Flash movie or layer, to show through all the transparent portions of the movie. This allows you to overlap the movie with other elements of the HTML page. Animation performance might be slower when you use this value.
当选用window模式时,flash对象有自己的窗口句柄,此时它已脱离于当前文档流,浏览器提供的视频弹出功能因而能够检测到它的窗口句柄,所以出现上面的那个问题。而窗口模式为Opaque和transparent时,该flash对象依然位于文档流中,此时可以通过z-index控制该flash在文档流中的纵向显示层级。