• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

Flash elements over CSS menu

Sometimes when you have CSS based navigation, it just doesn't work right with embedded flash elements.

To fix this, all you have to do is to set attribute wmode to transparent. But what if you have a CMS, where you can't control user input and you can't ask users to modify code. Then this function will help:

function fix_flash() 
    // loop through every embed tag on the site
    var embeds = document.getElementsByTagName('embed');
    for(i=0; i<embeds.length; i++)  
        embed = embeds[i];
        var new_embed;
        // everything but Firefox & Konqueror
            var html = embed.outerHTML;
            // replace an existing wmode parameter
            new_embed = html.replace(/wmodes*=s*('|")window('|")/i
            // add a new wmode parameter
            new_embed = html.replace(/<embeds/i,"<embed wmode='transparent' ");
            // replace the old embed object with the fixed version
        } else {
            // cloneNode is buggy in some versions of Safari & Opera, but works fine in FF
            new_embed = embed.cloneNode(true);
            if(!new_embed.getAttribute('wmode') || 

It goes through every embed element and sets attribute wmode to transparent. Just add it to onload event.

You may also be interested in:

Powered by

blog comments powered by Disqus