First, create an independent Javascript file (such as flash. JS) to add a Flash Player.CodeAs follows:
Function Createflash (idad, swfurl, Wad, had, ){
VaR Str = " <Object classid = \ "CLSID: d27cdb6e-ae6d-11cf-96b8-444553540000 \" codebase = \ "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab?version=7,0, 0 \" width = \" " + Wad + " \ "Height = \" " + Had + " \ "Id = \" " + Idad + " \ "Align = \" Middle \ "> " ; Str + = " <Param name = \ "allowScriptAccess \" value = \ "always \"> " ; Str + = " <Param name = \ "Quality \" value = \ "High \"> " ; Str + = " <Param name = \ "wmode \" value = \ "Opaque \"> " ; Str + = " <Param name = \ "movie \" value = \" " + Swfurl + " \ "> " ; Str + = " <Param name = \ "flashvars \" value = \" " + VS + " \ "> " ; Str + = " <Embed src = \" " + Swfurl + " \ "Flashvars = \" " + VS + " \ "Quality = \" High \ "wmode = \" Opaque \ "width = \" " + Wad + " \ "Height = \" " + Had + " \ "Name = \" " + Idad + " \ "Align = \" Middle \ "allowScriptAccess = \" always \ "type = \" application/X-Shockwave-Flash \ "pluginspage = \" http://www.macromedia.com/go/getflashplayer\ "> " ; Str + = " </Object> " ; Document. Write (STR );}
Then, create an XML file (such as inddata. XML) to save the path address of the image. The Code is as follows:
< Data >
< L Big = "Big_img/big_img1.jpg" Small = "Small_img/small_img1.jpg" URL = "Http://xugang.cnblogs.com" />
< L Big = "Big_img/big_img2.jpg" Small = "Small_img/small_img2.jpg" URL = "Http://xugang.cnblogs.com" />
< L Big = "Big_img/big_img3.jpg" Small = "Small_img/small_img3.jpg" URL = "Http://xugang.cnblogs.com" />
</ Data >
Note: Specify the address path of the large image and small icon in the XML file.
Finally, write the following code in the HTML file of the webpage:
<! -- Add JS references to the head label. -->
< Script SRC = "../JS/flash. js" Language = "JavaScript" > </ Script >
......
<! -- Add the flash code to the body tag. -->
< Div Class = "Bnrind" >
< Script Language = "JavaScript" >
// When initializing flash, it contains the XML Path
Createflash ( " Banner " , " ../Aboutus/banner.swf " , 1002 , 280 , " Data = inddata. xml " );
</ Script >
</ Div >
The effect is as follows:
<Div class = "bnrind"> <br/> </div> <br/>
[Ctrl + A select all tips: you can modify some code and then press run]
Sample download