hfyb

如何实现网页中动态切换的flash广告

            在需要添加flash广告的地方,嵌入javascript代码段:
            <script language=javascript>
             document.write(
            \'<embed    src="flash文件名.swf"   
            wmode="opaque"   
            FlashVars="pics=u/图片名.jpg|u/图片名.jpg|u/图片名.jpg|u/图片名.jpg|u/图片名.jpg
            &links=u/图片1指向的URL地址|u/图片2指向的URL地址|u/图片3指向的URL地址|u/图片4指向的URL地址|u/图片5指向的URL地址
            &texts=图片链接1显示的文本|图片链接2显示的文本|图片链接3显示的文本|图片链接4显示的文本|图片链接5显示的文本
            
&borderwidth=250&borderheight=160&textheight=20" menu="false" bgcolor="#DADADA" quality="high" width="250" height="180" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"/>\'); 
            </script>    
            这样就可以了。
            还可以这样做:
            <SCRIPT type=text/javascript>
            imgurl1="/图片名.jpg";
            imgtext1="图片链接1显示的文本"
            imglink1=escape("/图片1指向的URL地址");
            imgurl2="/图片名.jpg";
            imgtext2="图片链接2显示的文本"
            imglink2=escape("/图片2指向的URL地址");
            imgurl3="/图片名.jpg";
            imgtext3="图片链接3显示的文本"
            imglink3=escape("/图片3指向的URL地址");
            imgurl4="/图片名.jpg";
            imgtext4="图片链接4显示的文本"
            imglink4=escape("/图片4指向的URL地址");
            imgurl5="/图片名.jpg";
            imgtext5="图片链接5显示的文本"
            imglink5=escape("/图片5指向的URL地址");
            var focus_width=188
            var focus_height=157
            var text_height=0
            var swf_height = focus_height+text_height
 
            var pics=imgurl1+"|"+imgurl2+"|"+imgurl3+"|"+imgurl4+"|"+imgurl5           
            var links=imglink1+"|"+imglink2+"|"+imglink3+"|"+imglink4+"|"+imglink5
            var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4+"|"+imgtext5
 
 document.write(\'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"       
                           codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0
                           width="\'+ focus_width +\'" 
                           height="\'+ swf_height +\'">\');
 document.write(\'<param name="allowscriptaccess" value="samedomain">
                          <param name="movie" value="/flash文件名.swf">
                          <param name="quality" value="high"><param name="bgcolor" value="#f0f0f0">\');
 document.write(\'<param name="menu" value="false">
                          <param name=wmode value="opaque">\');
 document.write(\'<param name="flashvars"value="pics=\'+pics+\'&links=\'+links+\'&texts=\'+texts+\'
                          &borderwidth=\'+focus_width+\'&borderheight=\'+focus_height+\'&textheight=\'+text_height+\'">\');
 document.write(\'<embed src="/flash文件名.swf" 
                          wmode="opaque"      
                          flashvars="pics=\'+pics+\'&links=\'+links+\'&texts=\'+texts+\'
                          &borderwidth=\'+focus_width+\'
                          &borderheight=\'+focus_height+\'
                          &textheight=\'+text_height+\'" 
                          menu="false" bgcolor="#f0f0f0" 
                          quality="high" width="\'+ focus_width +\'" height="\'+ focus_height+\'"                      
                          allowscriptaccess="samedomain" type="application/x-shockwave-flash"                   
                          pluginspage="http://www.macromedia.com/go/getflashplayer" />\'); 
document.write(\'</object>\');
                         </script>                   

分类:

技术点:

相关文章: