給flash添加A鏈接


項目中,曾有一個需求,給flash廣告添加鏈接,跳轉到另一個網站。於是直接在html的flash object前面加上<a href="url">,發現鏈接不起作用。

  

解決方案:

以下各種嘗試的解決方案,方式三為最佳實踐!

 

【方式一】在flash外圍添加 <a href=...> 標簽 

【效    果】無效!

 

<html>
<head>
    <title>給flash添加鏈接</title>
</head>
<body>
<h3>方式一:在flash外圍添加 a href=... 標簽</h3>

<div>
    <!--此處添加鏈接-->
    <a href="url" target="_blank" style="text-decoration:none">
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" 
    width="192" height="136">            
            <param name="movie" value="fla/xxx.swf"><!--此處添加flash-->
            <param name="quality" value="high">
            <!--此處添加flash-->
            <embed src="fla/xxx.swf" quality="high" 
                pluginspage="http://www.macromedia.com/go/getflashplayer" 
                type="application/x-shockwave-flash" width="192" height="136"></embed>
    </object></a>
</div>
</body>
</html>

 

 

【方式二】用一個透明的大button包在flash的最外層,或是用一個層蓋住flash,然后定義button的onclick事件

【效    果】有效,但用戶最關心的SEO作用消失,因為該跳轉由JS實現!

 

<html>
<head>
    <title>給flash添加鏈接</title>
</head>
<body>
<h3>方式二:用一個透明的大button包在flash的最外層,或是用一個層蓋住flash,然后定義button的onclick事件</h3>
<div>    
    <button style="width:192;height:136;background:transparent;border:0; margin:0; padding:0;cursor:hand"
    onclick="window.open('url')"><!--此處添加鏈接-->
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" 
    width="192" height="136">        
        <param name="movie" value="fla/xxx.swf"><!--此處添加flash-->
        <param name="quality" value="high">
        <param name="wmode" value="transparent">
        <!--此處添加flash-->
        <embed src="fla/xxx.swf" width="192" height="136" quality="high" 
            pluginspage="http://www.macromedia.com/go/getflashplayer" 
            type="application/x-shockwave-flash" wmode="transparent"></embed>
    </object>
    </button>
</div>
</body>
</html>

 

 

【方式三】用一個透明圖鏈接蓋住flash,再利用div的zindex屬性將flash放在zindex=-1的層,同時設置wmode="transparent"

【效    果】有效!滿足各方需求!

 

<html>
<head>
    <title>給flash添加鏈接</title>
</head>
<body>
<h3>方式三:用一個透明圖鏈接蓋住flash,再利用div的zindex屬性將flash放在zindex=-1的層,同時設置wmode="transparent"</h3>
<div style="z-index:-1"><!-- 設置z-index屬性為-1 -->
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" 
    width="192" height="136">
        <param name="movie" value="fla/xxx.swf" /><!--此處添加flash-->
        <param name="quality" value="high" />
        <param name="wmode" value="opaque" />
        <!--此處添加flash-->
        <embed src="fla/xxx.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="192" height="136"></embed>
        </object>
</div>
<div id="masker" 
style="cursor: hand; margin-top:-136px; width:192px; height:136px; z-index:1; visibility: visible; border:0;">
    <!--此處添加鏈接-->
    <a href="url" target="_blank" style="text-decoration:none;">
    <!--此處添加遮蓋flash的透明圖片-->
    <img src="images/flashMasker.gif" width="192" height="136" border="0" /></a>
</div>
</body>
</html>

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM