Skip to content Skip to sidebar Skip to footer

Changing Arbitrary Flash Objects Wmode To Transparent

I need to change wmode of arbitrary flash objects to transparent from external js file to make sure they don't hide menus without using Jquery or similar libs. In FF I use getEleme

Solution 1:

I've been successful with this little trick:

$("embed").attr("wmode", "opaque").wrap('<div>');

It effectively redraws the flash object, worked for me.

Solution 2:

Cirday's solution in general is the right one. Here's a non-jQuery version, that works in IE, FF and Chrome:

var embed = document.getElementsByTagName('embed');
for(var i = 0; i < embed.length; i++){
    embed[i].setAttribute('wmode','opaque');
}
// FF does a "live" array when working directly with elements,// so "els" changes as we add/remove elements; to avoid problems// with indexing, copy to a temporary arrayvar els = document.getElementsByTagName('object');
var obj = [];
for(var i = 0; i < els.length; i++){
   obj[i] = els[i];
}
for(var i = 0; i < obj.length; i++){
    var param = document.createElement('param');
    param.setAttribute('name','wmode');
    param.setAttribute('value','opaque');
    obj[i].appendChild(param);

    var wrapper = document.createElement('div');
    obj[i].parentNode.appendChild(wrapper);

    if(obj[i].outerHTML){
        // IEvar html = obj[i].outerHTML;
        obj[i].parentNode.removeChild(obj[i]);
        wrapper.innerHTML = html;
    }else{
        // ff/chrome
        obj[i].parentNode.removeChild(obj[i]);
        wrapper.appendChild(obj[i]);
    }
}

Solution 3:

When you are using SWFObject to include the flash, there should be a parameter in the embedSWF method called 'params'. You pass it an object into it like this:

swfobject.embedSwf(blah,blah,blah, { wmode:'transparent'});

more here

Solution 4:

I'm almost 100% sure that you cannot change the wmode parameter at runtime. I mean, you technically can, but won't have any effect. I'm actually surprised that you got any successful attempts. What Flash player version and browser did you try successfully?

I'm sorry I can't find any official link to prove my point, but I'll leave you this very interesting link about how wmode works (updated to player 10):

What does GPU acceleration mean?

Cheers,

Juan

Post a Comment for "Changing Arbitrary Flash Objects Wmode To Transparent"