SWFObject | JavaScriptSource


Geoff Stearns Oct 10, 2007


This small JavaScript file is used for embedding Adobe Flash content. The script can detect the Flash plug-in in all major Web browsers (on Mac and PC) and is designed to make embedding Flash movies as easy as possible. It is also very search engine friendly, degrades gracefully, can be used in valid HTML and XHTML 1.0 documents, and is forward compatible, so it should work for years to come.

This text is replaced by the Flash movie.


Create a new SWFObject and pass in the required arguments:

var so = new SWFObject(swf, id, width, height, version, background-color [, quality, xiRedirectUrl, redirectUrl, detectKey]);

  • swf - The file path and name to your swf file.
  • id - The ID of your object or embed tag. The embed tag will also have this value set as it's name attribute for files that take advantage of swliveconnect.
  • width - The width of your Flash movie.
  • height - The height of your Flash movie.
  • version - The required player version for your Flash content. This can be a string in the format of 'majorVersion.minorVersion.revision'. An example would be: "6.0.65". Or you can just require the major version, such as "6".
  • background-color - This is the hex value of the background color of your Flash movie.

Optional arguments are:

  • quality - The quality you wish your Flash movie to play at. If no quality is specified, the default is "high".
  • xiRedirectUrl - If you would like to redirect users who complete the ExpressInstall upgrade, you can specify an alternate URL here
  • redirectUrl - If you wish to redirect users who don't have the correct plug-in version, use this parameter and they will be redirected.
  • detectKey - This is the url variable name the SWFObject script will look for when bypassing the detection. Default is 'detectflash'. Example: To bypass the Flash detection and simply write the Flash movie to the page, you could add ?detectflash=false to the url of the document containing the Flash movie.

For additional details, visit: http://blog.deconcept.com/swfobject/

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: swfobject.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response


Due to the limitations of these comments, you will need to submit your question to the [a href="http://www.webdeveloper.com/forum/forumdisplay.php?f=3"]JavaScript Forum[/a] for further help.

Lee Underwood Jan 29, 2008

Thanks for the code, I would like to say it's working but unfortunately it's not.[br /][br /]I see the text on the page and that is all.[br /][br /]IE 6 SP2[br /]XP SP2[br /]Flash 8[br /][br /]Any suggestions appreciated.

Mark Dec 18, 2007

Yes, put whatever you want the visitor to see if they don't have Flash. Also, it's used by the search engines so you will want to use keywords in your description.

Lee Oct 26, 2007

I have a little confused about the what exactly I should put in the "flashcontent" section - should I place text explaining the movie? or what?[br /][br /]Text below:[br /][br /]<div id="flashcontent">[br /] This text is replaced by the Flash movie. You can place information here for the search engines.[br /]</div>

ct2k 12830 Oct 14, 2007

I am using the javascript utility provided by you for embedding flash movie files in my project. I am very happy to use it and wanted to thank you for it.[br /]Keep it up.

sanjay Oct 12, 2007