views:

69

answers:

1

Hi every one, im trying to fix the flash overlap using regular expressions. here is an example of markup im trying to convert to my needs

  <object width="440" height="300" data=
  "http://www.youtube.com/v/dMH0bHeiRNg&amp;amp;color1=0xb1b1b1&amp;amp;color2=0xd0d0d0&amp;amp;hl=en_US&amp;amp;feature=player_embedded&amp;amp;fs=1"
  type="application/x-shockwave-flash">
    <param name="allowScriptAccess" value="never" />
    <param name="allowNetworking" value="internal" />
    <param name="wmode" value="window" />
    <param name="movie" value=
    "http://www.youtube.com/v/dMH0bHeiRNg&amp;amp;color1=0xb1b1b1&amp;amp;color2=0xd0d0d0&amp;amp;hl=en_US&amp;amp;feature=player_embedded&amp;amp;fs=1" />
    <!--[if IE]><embed width="440" height="300" src="http://www.youtube.com/v/dMH0bHeiRNg&amp;amp;color1=0xb1b1b1&amp;amp;color2=0xd0d0d0&amp;amp;hl=en_US&amp;amp;feature=player_embedded&amp;amp;fs=1" allowScriptAccess="never" allowNetworking="internal" wmode="window"><![endif]-->
  </object>

i want a function using regluar expressions that 1) checks presence of <param name="wmode" ..... if it exists... it forcefully sets value to 'opaque'. if doesn't exists it adds it to the above code.

I need this function to solve flash overlap problems of 'html' code saved in database

+1  A: 

I fixed it by calling this function(below) within $(document).ready function.

window.fix_wmode2transparent_swf = function  () {
    // For embed
    jQuery("embed").each(function(i) {
        var elClone = this.cloneNode(true);
        elClone.setAttribute("WMode", "Transparent");
        jQuery(this).before(elClone);
        jQuery(this).remove();
    });    
    // For object and/or embed into objects
    jQuery("object").each(function (i, v) {
    var elEmbed = jQuery(this).children("embed");
    if(typeof (elEmbed.get(0)) != "undefined") {
        if(typeof (elEmbed.get(0).outerHTML) != "undefined") {
            elEmbed.attr("wmode", "transparent");
            jQuery(this.outerHTML).insertAfter(this);
            jQuery(this).remove();
        }
        return true;
    }
    var algo = this.attributes;
    var str_tag = '<OBJECT ';
    for (var i=0; i < algo.length; i++) str_tag += algo[i].name + '="' + algo[i].value + '" ';    
    str_tag += '>';
    var flag = false;
    jQuery(this).children().each(function (elem) {
        if(this.nodeName == "PARAM") {
            if (this.name == "wmode") {
                flag=true;
                str_tag += '<PARAM NAME="' + this.name + '" VALUE="transparent">';        
            }
            else  str_tag += '<PARAM NAME="' + this.name + '" VALUE="' + this.value + '">';
        }
    });
    if(!flag)
        str_tag += '<PARAM NAME="wmode" VALUE="transparent">';        
    str_tag += '</OBJECT>';
    jQuery(str_tag).insertAfter(this);
    jQuery(this).remove();    
    });
}

source

http://www.nobilesoft.com/Scripts/fix_wmode2transparent_swf.js

Sir Lojik