網頁中flash wmode屬性你會用嗎?
2019-10-26 17:24:16
供稿:網友
在做web開發中可能會遇到flash遮擋頁面中元素的情況,無論怎么設置flash容器和層的深度(z-index)也無濟于事,現有的解決方案是在插入flash的embed或object標簽中加入”wmode”屬性并設置為wmode=“transparent”或”opaque”,但wmode屬性到底是什么意義,為什么可以解
在flash標簽中
<param name=”wmode" value="xxxx">
"Window" 在 Web 頁上用影片自己的矩形窗口來播放應用程序,并且始終位于最頂層。
"Opaque" 顯示頁面上位于它后面的內容。
"Transparent"使 HTML 頁的背景可以透過應用程序的所有透明部分顯示出來,并且可能會降低動畫性能。
注:"Opaque"和"Transparent"都可與 HTML 層交互,從而允許 SWF 文件上方的層遮蔽應用程序。這兩種選項之間的差異在于"Transparent"允許透明,因此,如果 SWF 文件的某一部分是透明的,則 SWF 文件下方的 HTML 層可以透過該部分顯示出來,而"opaque"則不會顯示。
也就是如果發生FLASH遮蓋DIV層的情況,就必須要改wmode屬性為“Transparent”
在做web開發中可能會遇到flash遮擋頁面中元素的情況,無論怎么設置flash容器和層的深度(z-index)也無濟于事,現有的解決方案是在插入flash的embed或object標簽中加入”wmode”屬性并設置為wmode=“transparent”或”opaque”,但wmode屬性到底是什么意義,為什么可以解決這個問題呢?
window mode(wmode)
wmode即窗口模式總共有三種,看看當年Macromedia官方的說法: 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 player有自己的窗口句柄,這就意味著flash影片是存在于Windows中的一個顯示實例,并且是在瀏覽器核心顯示窗口之上的,所以flash只是貌似顯示在瀏覽器中,但這也是flash最快最有效率的渲染模式。由于他是獨立于瀏覽器的HTML渲染表面,這就導致默認顯示方式下flash總是會遮住位置與他重合的所有DHTML層。