Summary of swfobject flash insertion

Source: Internet
Author: User

First http://code.google.com/p/swfobject/

"Swfobject" uses JavaScript to insert Flash. It has many advantages and simple code. It does not prompt "Click here to activate the control" under IE6 and can pass W3C verification. Different from the traditional flash Insertion Method of "object.

Swfobject in the new 2. in Version X, the simplest call requires only one sentence and does not need to wait for the page to load. This means that you can write this sentence anywhere on the page. It is much easier than the previous version. The following describes several simple and commonly used call methods:

1. the simplest and most basic sentence, which can be used as long as you want to insert Flash.

<SCRIPT type = "text/JavaScript" src = "swfobject. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
Swfobject. embedswf ("test.swf", "swfid", "300", "120", "9.0.0", "expressinstall.swf ");
</SCRIPT>
<Div id = "swfid"> </div>

Parameter annotation: Call method embedswf -- Insert the SWF file. The parameters are as follows:
@ SWF file address;
@ ID of the container (such as Div) used to load the SWF file;
@ Flash width;
@ Flash height (of course, the width and height can be expressed by a percentage such as 100% );
@ The lowest version required for normal playback of the flash;
@ When the version is earlier than the required version, execute the SWF file. Here, use this flash to go to the official download of the latest flash plug-in. (This parameter can be omitted)
When inserting multiple Flash files to different locations on the same page, you only need to repeat the preceding statement and use different container IDs.

2. Call methods for passing parameters, variables, and attributes to the SWF File

<SCRIPT type = "text/JavaScript" src = "swfobject. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
// 1. Use JSON to initialize variables, parameters, and attributes
VaR flashvars = {
Name1: "hello ",
Name2: "world ",
Name3: "foobar"
};
VaR Params = {
Menu: "false"
};
VaR attributes = {
ID: "dynamiccontent2 ",
Name: "dynamiccontent2"
};
Swfobject. embedswf ("test6_flashvars.swf", "content2", "300", "120", "6.0.0", "expressinstall.swf", flashvars, Params, attributes );
// 2. Traditional initialization settings have the same effect
VaR flashvars = {};
Flashvars. name1 = "hello ";
Flashvars. name2 = "world ";
Flashvars. name3 = "foobar ";
VaR Params = {};
Params. Menu = "false ";
VaR attributes = {};
Attributes. ID = "dynamiccontent3 ";
Attributes. Name = "dynamiccontent3 ";
Swfobject. embedswf ("test6_flashvars.swf", "content3", "300", "120", "6.0.0", "expressinstall.swf", flashvars, Params, attributes );
// 3. Write it directly at the back end, just a word, concise and tough, without dragging the water
Swfobject. embedswf ("test6_flashvars.swf", "content5", "300", "120", "6.0.0", "expressinstall.swf", {name1: "hello", name2: "world ", name3: "foobar" },{ menu: "false" },{ ID: "dynamiccontent5", name: "dynamiccontent5 "});
</SCRIPT>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.