焦點圖片新聞,是通過壹個 Flash 文件來調用圖片,使圖片交互切換。其中變量:
pics: 指明交替的圖片路徑,以“|”進行分隔;
links: 指明點擊每幅圖片打開的鏈接,以“|”進行分隔,與 pics 的圖片壹壹對應;
texts: 指明每幅圖片的文字說明,以“|”進行分隔,與 pics 的圖片壹壹對應;
focus_width: 指明 Flash 中圖片的寬度;
focus_height: 指明 Flash 中圖片的高度;
text_height: 指明 Flash 中說明文字所占的高度;
swf_height: 為 Flash 的高度。
經測試,圖片只支持JPG格式的文件。
分析整理出如下代碼:
源代碼
1<script type="text/javascript">
2 <!--
3
4 var focus_width = 375; // 圖片寬度
5 var focus_height= 500; // 圖片高度
6 var text_height = 20; // 顯示的文字高度
7 var swf_height = focus_height + text_height;
8
9 var pics ="3643603.jpg|3644310.jpg|3647102.jpg|3649097.jpg|3646832.jpg|3649095.jpg|3649096.jpg";
10 var links="3643603.jpg|3644310.jpg|3647102.jpg|3649097.jpg|3646832.jpg|3649095.jpg|3649096.jpg";
11 var texts="3643603.jpg|3644310.jpg|3647102.jpg|3649097.jpg|3646832.jpg|3649095.jpg|3649096.jpg";
12
13 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ');
14 document.write('codebase="/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
15 document.write('width="'+ focus_width +'" ');
16 document.write('height="'+ swf_height +'">');
17 document.write('<param name="allowScriptAccess" value="sameDomain">');
18 document.write('<param name="movie" value="focus.swf">');
19 document.write('<param name="quality" value="high">');
20 document.write('<param name="bgcolor" value="#ffffff">');
21 document.write('<param name="menu" value="false">');
22 document.write('<param name=wmode value="opaque">');
23 document.write('<param name="FlashVars" ');
24 document.write('value="pics='+pics);
25 document.write( '&links='+links);
26 document.write( '&texts='+texts);
27 document.write( '&borderwidth='+focus_width);
28 document.write( '&borderheight='+focus_height);
29 document.write( '&textheight='+text_height+'">');
30 document.write('<embed src="focus.swf" ');
31 document.write('wmode="opaque" ');
32 document.write('FlashVars="pics='+pics);
33 document.write( '&links='+links);
34 document.write( '&texts='+texts);
35 document.write( '&borderwidth='+focus_width);
36 document.write( '&borderheight='+focus_height);
37 document.write( '&textheight='+text_height+'" ');
38 document.write('menu="false" ');
39 document.write('bgcolor="#ffffff" ');
40 document.write('quality="high" ');
41 document.write('width="'+ focus_width +'" ');
42 document.write('height="'+ focus_height +'" ');
43 document.write('allowScriptAccess="sameDomain" ');
44 document.write('type="application/x-shockwave-flash" ');
45 document.write('pluginspage="/go/getflashplayer" />');
46 document.write('</object>');
47
48 //-->
49</script>
50
這是壹個例子,我自己做了壹遍,完全能實現。