Link to home
Start Free TrialLog in
Avatar of nagki
nagki

asked on

Changing the wmode of flash on the fly with javascript

Hi,

I have a drop-down in a page that's coming over flash with default wmode.
After a long search, I read in the Adobe site that the only solution to get other DHTML layers over flash is setting wmode="transparent" . But, setting "wmode" to "transparent" is taking around 20%CPU always.

So, I am trying a way to set wmode on the fly with JavaScript. so, whenever needed , I will change the wmode to transparent and revert it back once done.

I tried this :
document.getElementById("FlashChart").setAttribute("wmode","transparent");  //FlashChart is the name of the flash given in embed tag

But its not working..Any Idea?
ASKER CERTIFIED SOLUTION
Avatar of mreuring
mreuring
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amonthmind
amonthmind

// erratic behavior but close, not tested in other than IE

function changeWMode(id, wmode)
{
      var el = document.getElementById(id);
      var child = null;
      var param = el.createElement('param');
      param.name = 'wmode';
      param.value = wmode;
      el.appendChild(param);
      for (var i=0, end = el.childNodes.length; i < end; i++)
      {
            child = el.childNodes[i];
            if (child.nodeName === 'EMBED')
            {
                  child.wmode = wmode;
            }
      }
}