如何讓flash不遮擋html div元素的技巧

字號(hào):


    今天在寫一個(gè)flash廣告代碼的時(shí)候,因?yàn)閒lash自帶的鏈接,容易被當(dāng)成彈出廣告,所以做了一個(gè)div層放到flash上面,這樣鏈接都是a觸發(fā)的不會(huì)被攔截,但發(fā)現(xiàn)flash一直處于div層上面,原來(lái)flash需要加個(gè)參數(shù)才可以。
    讓flash置于div層之下的方法,讓flash不擋住飄浮層或下拉菜單,讓flash不檔住浮動(dòng)對(duì)象或?qū)拥年P(guān)鍵參數(shù):wmode=opaque。
    方法如下:
    針對(duì)ie 在<object></object>內(nèi)加上參數(shù)<param name=wmode value=opaque />
    針對(duì)ff 在<embed />內(nèi)加上參數(shù)wmode=opaque
    腳本之家使用代碼:
    xml/html code復(fù)制內(nèi)容到剪貼板
    <!doctype html public -//w3c//dtd xhtml 1.0 transitional//en >
    <html xmlns=>
    <head>
    <meta http-equiv=content-type content=text/html; charset=gb2312 />
    <title>22cn</title>
    <style type=text/css>
    <!--
    body {
    position:relative;
    z-index:0;
    margin:0; padding:0
    }
    body,td,th {
    color: #333333;
    }
    *{margin:0; padding:0}
    img{ border:0}
    #jb51{ position:relative; width:300px; height:250px}
    #div1 {
    position:absolute;
    left:0;
    top:0;
    width:300px;
    height:250px; z-index:-1
    }
    #div2 {
    position:absolute;
    left:0;
    top:0;
    width:300px;
    height:250px;
    z-index:99999;
    }
    -->
    </style></head>
    <body>
    <div id=jb51>
    <div id=div1>
    <script type=text/javascript>
    document.write('<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase= width=300 height=250>');
    document.write('<param name=movie value= />');
    document.write('<param name=quality value=high /><param name=wmode value=opaque />');
    document.write('<embed src= quality=high pluginspage= type=application/x-shockwave-flash width=300 height=250 wmode=opaque></embed>');
    document.write('</object>');
    </script>
    </div>
    <div id=div2>
    <a href= target=_blank><img src= width=300 height=250/></a>
    </div>
    </div>
    </body>
    </html>
    標(biāo)準(zhǔn)的的flash插入
    xml/html code復(fù)制內(nèi)容到剪貼板
    <!-- 標(biāo)準(zhǔn)的的flash插入
    設(shè)置高度與寬度:
    width=400 height=400
    設(shè)置路徑:
    data=style/flash/001.swf 與 value=style/flash/001.swf
    替代文本或替代圖片:
    <a href= title=><img src= alt= /></a> 也可以不要這段
    -->
    <object type=application/x-shockwave-flash data=style/flash/001.swf width=400 height=400>
    <param name=movie value=style/flash/001.swf />
    <a href=style/flash/001.swf><img src=style/img/001.jpg alt=flash動(dòng)畫(huà) /></a>
    </object>
    不會(huì)遮住層的flash
    xml/html code復(fù)制內(nèi)容到剪貼板
    <!-- 不會(huì)遮住層的flash
    讓flash不檔住浮動(dòng)對(duì)象或?qū)拥年P(guān)鍵屬性:
    <param name=wmode value=opaque />
    <embed wmode=opaque></embed>
    -->
    <object type=application/x-shockwave-flash data=style/flash/001.swf width=400 height=400>
    <param name=movie value=style/flash/001.swf />
    <param name=wmode value=opaque />
    <embed wmode=opaque></embed>
    <a href=style/flash/001.swf><img src=style/img/001.jpg alt=flash動(dòng)畫(huà) /></a>
    </object>
    透明的flash
    xml/html code復(fù)制內(nèi)容到剪貼板
    <!-- 透明的flash
    讓flash透明的關(guān)鍵屬性:
    <param name=wmode value=transparent>
    -->
    <object type=application/x-shockwave-flash data=style/flash/001.swf width=400 height=400>
    <param name=movie value=style/flash/001.swf />
    <param name=wmode value=transparent>
    <a href=style/flash/001.swf><img src=style/img/001.jpg alt=flash動(dòng)畫(huà) /></a>
    </object>
    wmode 屬性/參數(shù)值 window | opaque | transparent
    模板變量:$wm,(可選)允許使用 internet explorer 4.0 中的透明 flash 內(nèi)容、絕對(duì)定位和分層顯示功能。此標(biāo)記/屬性僅在帶有 flash player activex 控件的 windows 中有效。
    window在 web 頁(yè)上用影片自己的矩形窗口來(lái)播放應(yīng)用程序。window表明此 flash 應(yīng)用程序與 html 層沒(méi)有任何交互,并且始終位于最頂層。
    opaque 使應(yīng)用程序隱藏頁(yè)面上位于它后面的所有內(nèi)容。
    transparent使 html 頁(yè)的背景可以透過(guò)應(yīng)用程序的所有透明部分顯示出來(lái),并且可能會(huì)降低動(dòng)畫(huà)性能。
    opaque windowless和transparent windowless都可與 html 層交互,從而允許 swf 文件上方的層遮蔽應(yīng)用程序。這兩種選項(xiàng)之間的差異在于transparent允許透明,因此,如果 swf 文件的某一部分是透明的,則 swf 文件下方的 html 層可以透過(guò)該部分顯示出來(lái),而opaque則不會(huì)顯示。
    如果忽略此屬性,默認(rèn)值為 window。僅適用于 object。