简体   繁体   中英

swfobject : how to add html title attribute to object (flash)

I use swfobject.js file to embed flash content onto my website. How does one add the html title attribute to the flash-object embed through it.

Since, some of the browsers do show the title of the object on mouseover or in status, as a tooltip or in browser status. [ Eg. IE6 and Opera ]

Please help

Anita

You can pass in variables to a Flash file, and enable the tooltip in a cross-platform way.

so.addVariable("var", "value"); 

Get the value from DOM:

document.title

So:

var mytitle;
var = document.title;
so.addVariable("mytitle", mytitle); 

Using SWFObject 2.2

var attributes = {
   title: document.title
};
swfobject.embedSWF("mymovie.swf", //URL for SWF file
                   "mytargetdiv", //Target element
                   "550",         //SWF width
                   "400",         //SWF height
                   "9",           //Minimum required version of Flash Player
                   false,         //Path to ExpressInstall SWF (if desired)
                   false,         //Flashvars (if desired)
                   false,         //Parameters (if desired)
                   attributes);   //Attributes (if desired)

This assumes your <title> element is placed before your <script> element in your page's markup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM