html元素遮擋flash詳解示例

字號:


    代碼如下:
    wmode參數(shù):
    transparent模式:可用z-index控制層級
    opaque模式:可用z-index控制層級
    window模式:flash層級在瀏覽器核心顯示窗口之上,flash會蓋住與他重合的html
    情景1(可修改flash的wmode參數(shù))
    修改wmode屬性為,transparent或opaque
    DEMO如下:
    代碼如下:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title> HTML元素遮擋Flash - 情景1 </title>
    <style>
    html, body, object, embed{ padding: 0; margin: 0; }
    .m-box { position: relative; }</p> <p> .m-flash, .m-flash embed { width: 400px; }
    .m-shadow { position: absolute; top: 0; left: 0; width: 100px; height: 100px; background-color: #ccc; }
    </style>
    </head>
    <body>
    <!--transparent-->
    <div>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
    <param name="src" value="<a href=">">
    <param name="wmode" value="transparent"/>
    <embed wmode="transparent" src="<a href=">>
    </object></p> <p> <div>
    Jununx,歡迎您!--transparent
    </div>
    </div></p> <p><!--opaque-->
    <div>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
    <param name="src" value="<a href=">">
    <param name="wmode" value="opaque"/>
    <embed wmode="opaque" src="<a href=">>
    </object></p> <p> <div>
    Jununx,歡迎您!--opaque
    </div>
    </div></p> <p></body>
    </html>
    情景2(不可修改flash的wmode參數(shù))-- flash和你的iframe遮擋層在同一個頁面
    注:如果要兼容Safari、Opera,那么請直接告訴需求這個遮不了
    DEMO如下:
    代碼如下:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title> HTML元素遮擋Flash - 情景2 </title>
    <style>
    html, body, object, embed{ padding: 0; margin: 0; }
    .m-box { position: relative; }</p> <p> .m-flash, .m-flash embed { width: 400px; }
    .m-flash { position: relative; z-index: 1; }
    .m-shadow { position: absolute; top: 0; left: 0; z-index: 2; width: 100px; height: 100px; background-color: #ccc; }
    .m-shadow-txt { position: absolute; z-index: 2; }
    .m-shadow-ifr { position: absolute; z-index: -1; width: 100%; height: 100%; opacity: 0; filter: alpha(opacity=0); }
    </style>
    </head>
    <body>
    <!--window-->
    <div>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
    <param name="src" value="<a href=">">
    <param name="wmode" value="window"/>
    <embed wmode="window" src="<a href=">>
    </object></p> <p> <div>
    <div>Jununx,歡迎您!--window</div>
    <iframe frameborder="0"></iframe>
    </div>
    </div></p> <p></body>
    </html>
    情景3(不可修改flash的wmode參數(shù))-- flash是被一個iframe頁面引入的
    注:如果木有權(quán)限操作iframe頁面,那么請直接告訴需求這個遮不了注:如果要兼容Safari、Opera,那么請直接告訴需求這個遮不了
    DEMO頁:
    代碼如下:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title> HTML元素遮擋Flash - 情景2 </title>
    <style>
    html, body, object, embed{ padding: 0; margin: 0; }
    .m-box { position: relative; }</p> <p> .m-flash { position: relative; width: 400px; height: 400px; z-index: 1; }
    .m-shadow { position: absolute; top: 0; left: 0; z-index: 2; width: 100px; height: 100px; background-color: #ccc; }
    .m-shadow-txt { position: absolute; z-index: 2; }
    .m-shadow-ifr { position: absolute; z-index: -1; width: 100%; height: 100%; opacity: 0; filter: alpha(opacity=0); }
    </style>
    </head>
    <body>
    <!--window-->
    <div>
    <iframe src="ifr.html" frameborder="0"></iframe></p> <p> <div>
    <div>Jununx,歡迎您!--window</div>
    <iframe frameborder="0"></iframe>
    </div>
    </div></p> <p></body>
    </html>
    iframe頁:
    代碼如下:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title> HTML元素遮擋Flash - 情景3 </title>
    <style>
    html, body, object, embed{ padding: 0; margin: 0; }
    .ifr { position: absolute; z-index: 2; width: 100px; height: 100px; opacity: 0; filter: alpha(opacity=0); }
    .m-flash { position: absolute; z-index: 1; width: 400px; }
    </style>
    </head>
    <body>
    <!--window-->
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
    <param name="src" value="<a href=">">
    <param name="wmode" value="window"/>
    <embed wmode="window" src="<a href=">>
    </object></p> <p><iframe frameborder="0"></iframe>
    </body>
    </html>