• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5954
  • Last Modified:

Changing the wmode of flash on the fly with javascript


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?
1 Solution
The most likely cause, and I'm just talking of gut-feeling, is that the object won't be able to change the wmode without re-rendering the entire thing. To be honest, I'd be suprised if someone would prove me wrong!

If it were easy enough to render in wmode and be able to swap it on-the-fly you wouldn't have had the need to investigate this cause the CPU-load would have been negligable.

Now I would asume that you could re-render the object in wmode by cloning and replacing it, but something with a 20% CPU load would have to be in constant motion and thus cloning it would reset the movie.

I think the answer in the end will turn out to be: not possible. But I'm keen on finding out if anybody proves me wrong :)
// 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;
      for (var i=0, end = el.childNodes.length; i < end; i++)
            child = el.childNodes[i];
            if (child.nodeName === 'EMBED')
                  child.wmode = wmode;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now