关于 focus.swf 调用
最近发现诸如qq.com sina.com.cn sohu.com 都出现如下图所示的焦点图片新闻,查看其网页的源代码,发现它们都是通过一个 Flash 文件来调用图片,使图片交互切换。
分析整理出如下代码:
<script type="text/javascript"> var focus_width = 325; // 图片宽度 var focus_height= 135; // 图片高度 var text_height = 20; // 显示的文字高度 var swf_height = focus_height + text_height; var pics ="static/images/1464572379946249.jpg|static/images/1464572473888288.jpg|static/images/1434695448693300.jpg|static/images/1375860252118497.jpg"; var links="http://jjsg.2217.com/news/19658/|http://jjsg.2217.com/news/19699/|http://jjsg.tonnn.com/news/11907/|http://jjsg.tonnn.com/news/892/"; var texts=""; document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '); document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '); document.write('width="'+ focus_width +'" '); document.write('height="'+ swf_height +'">'); document.write('<param name="allowScriptAccess" value="sameDomain">'); document.write('<param name="movie" value="focus.swf">'); document.write('<param name="quality" value="high">'); document.write('<param name="bgcolor" value="#ffffff">'); document.write('<param name="menu" value="false">'); document.write('<param name=wmode value="opaque">'); document.write('<param name="FlashVars" '); document.write('value="pics='+pics); document.write( '&links='+links); document.write( '&texts='+texts); document.write( '&borderwidth='+focus_width); document.write( '&borderheight='+focus_height); document.write( '&textheight='+text_height+'">'); document.write('<embed src="focus.swf" '); document.write('wmode="opaque" '); document.write('FlashVars="pics='+pics); document.write( '&links='+links); document.write( '&texts='+texts); document.write( '&borderwidth='+focus_width); document.write( '&borderheight='+focus_height); document.write( '&textheight='+text_height+'" '); document.write('menu="false" '); document.write('bgcolor="#ffffff" '); document.write('quality="high" '); document.write('width="'+ focus_width +'" '); document.write('height="'+ focus_height +'" '); document.write('allowScriptAccess="sameDomain" '); document.write('type="application/x-shockwave-flash" '); document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); </script>
其中变量:
pics: 指明交替的图片路径,以“|”进行分隔;
links: 指明点击每幅图片打开的链接,以“|”进行分隔,与 pics 的图片一一对应;
texts: 指明每幅图片的文字说明,以“|”进行分隔,与 pics 的图片一一对应;
focus_width: 指明 Flash 中图片的宽度;
focus_height: 指明 Flash 中图片的高度;
text_height: 指明 Flash 中说明文字所占的高度;
swf_height: 为 Flash 的高度。
经测试,图片只支持JPG格式的文件。
示例代码及focus.swf下载: 点击下载
原文链接:http://www.cnblogs.com/zhuyiwen/archive/2006/06/07/420119.html

浙公网安备 33010602011771号