(EXT) Swfobject.js detailed explanation

Source: Internet
Author: User

Always want to do a summary of this application, today accidentally Baidu to this effect, to do a note.

The benefits of using this JS:

There is no annoying imaginary frame problem in 1.IE.
2. Provides a complete version of the detection function, if the version is not enough to show other things, than tablets or text.
3. Easy to use, as long as the page header loading a. js file, and then HTML to write a container, inside the normal text or pictures (for the display of the flash can not be displayed), and finally with a script to replace the contents of this element is Flash.
4. Make inserting flash media resources as simple and safe as possible. And it is very much in line with the principle of search engine optimization.
5. Can avoid non-standard tags such as object, embed, etc. in HTML, XHTML, to conform to the more standard.

Only need to include swfobject.js this JS file, and then insert some simple JS code in the DOM, you can embed the Flash media resources. Here is one of the simplest examples:

<script type= "Text/javascript" src= "swfobject.js" ></script><script type= "Text/javascript" >   var so = new SWFObject ("movie.swf", "Mymovie", "N", "100%", "8", "#336699");    So.addparam ("Quality", "low");   So.addparam ("wmode", "Transparent");   So.addparam ("salign", "T");   So.addvariable ("Variable1", "value1");   So.addvariable ("Variable2", "value2");   So.addvariable ("Variable3", "Value3");   So.addvariable ("Variable1", Getqueryparamvalue ("Variable1"));   So.addvariable ("Variable2", Getqueryparamvalue ("Variable2"));   So.write ("Flashcontent");</script>

  

<div id= "Flashcontent" >[...] </div> first, we want to reserve an HTML node for the SWF resource. Everything inside this HTML node is replaced by the Flash resource on the client, which is displayed when the client does not have a Flash player installed. This feature is essential in terms of SEO and user experience.

var so = new SWFObject (swf, ID, width, height, version, Background-color [, Quality, Xiredirecturl, RedirectURL, Detectkey ]); Create a new SWFObject instance and pass in the parameters:

swf-swf file path
ID-The ID value that you assign to this SWF file, which will be used to set the Name property for embed and the object tag, so that functions that can support swliveconnect, such as dynamically passing in variables
Width-Widths
Height-Altitude
Version-flashplayer requires the version number, which can be detailed to the ' major version number. ' Minor version number. Details ', for example: "6.0.65". In general, we just have to pass in the main version, for example: "6".
Background-color-flash Resource background color, 16 binary format
In addition, the following optional parameters are available:

Quality-screen quality, default to "high".
Xiredirecturl-See Expressinstall related
RedirectURL-The destination address of the auto-jump after the corresponding version of the player is not installed
Detectkey-This is when the detection is ignored, swfobject will go to the URL address to find the variable, the default value is "Detectflash", followed by detailed introduction
So.write ("flashcontent"); Apply the flash resource to the DOM and display it in the browser.

Explain the effects of these parameters:

var so = new SWFObject (swf, ID, width, height, version, Background-color [, Quality, Xiredirecturl, RedirectURL, Detectkey         ]); This is the basic parameter that SWFObject must have, and all swfobject must be included.
So.addparam ("Param1", "Param2"); This is the addition of inline parameters to flash, which enables effects such as background transparency. Add as required, parameters and emded/object tags are the same code, same as below.
So.addparam ("Param3", "Param4");
So.addparam ("PARAM5", "PARAM6");
So.addvariable ("Variable1", "value1"); Here is to add Flashvar to Flash, which is to add a variable to the root of flash in Flashvar way, for the number type variable on the flash side need to do type conversion.
So.addvariable ("Variable2", "value2");
So.addvariable ("Variable3", "value3");
So.addvariable ("Variable1", Getqueryparamvalue ("Variable1")); Flash get URL variable for Url?arg1=test1&arg2=test2 to pass a variable in a get way, we can use the Getqueryparamvalue method to get the variable.
So.addvariable ("Variable2", Getqueryparamvalue ("Variable2"));
So.write ("content"); This is a crucial place where he replaces the content that flash cannot display with a specific piece of content. You can define the styles in CSS beforehand and write them in the document using DIV tags. Here in call over.

(EXT) Swfobject.js detailed explanation

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.