これが私のコードです:
私のページにフラッシュ スライドショーがあります。ログインにシックボックスを使用しましたが、誰かがログインをクリックすると、フラッシュがシックボックスをオーバーレイします。
Firefox では問題を解決できましたが、Internet Explorer では何も動作しないようです。
OK、答えを求めて Web を 2 日間検索した後、すべてのブラウザーでそれを修正する純粋な JS 関数を見つけました!
そこに行きます:
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
if (embed.outerHTML) {
var html = embed.outerHTML;
// replace an existing wmode parameter
if (html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i, "wmode='transparent'");
// add a new wmode parameter
else
new_embed = html.replace(/<embed\s/i, "<embed wmode='transparent' ");
// replace the old embed object with the fixed version
embed.insertAdjacentHTML('beforeBegin', new_embed);
embed.parentNode.removeChild(embed);
} 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') || new_embed.getAttribute('wmode').toLowerCase() == 'window')
new_embed.setAttribute('wmode', 'transparent');
embed.parentNode.replaceChild(new_embed, embed);
}
}
// loop through every object tag on the site
var objects = document.getElementsByTagName('object');
for (i = 0; i < objects.length; i++) {
object = objects[i];
var new_object;
// object is an IE specific tag so we can use outerHTML here
if (object.outerHTML) {
var html = object.outerHTML;
// replace an existing wmode parameter
if (html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i, "<param name='wmode' value='transparent' />");
// add a new wmode parameter
else
new_object = html.replace(/<\/object\>/i, "<param name='wmode' value='transparent' />\n</object>");
// loop through each of the param tags
var children = object.childNodes;
for (j = 0; j < children.length; j++) {
try {
if (children[j] != null) {
var theName = children[j].getAttribute('name');
if (theName != null && theName.match(/flashvars/i)) {
new_object = new_object.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i, "<param name='flashvars' value='" + children[j].getAttribute('value') + "' />");
}
}
}
catch (err) {
}
}
// replace the old embed object with the fixed versiony
object.insertAdjacentHTML('beforeBegin', new_object);
object.parentNode.removeChild(object);
}
}
}
これで、ページが jQuery でロードされたときに実行できます。
$(document).ready(function () {
fix_flash();
}
次のフラッシュ オブジェクトでも同じ問題が発生しました。
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="690" height="400" id="tech" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="banner/banner.swf?xml_path=banner/slides.xml" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<embed src="banner/banner.swf?xml_path=banner/slides.xml" quality="high" width="690" height="400" name="tech" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<param name="wmode" value="opaque" />
That's the key to make it workという行に注意してください。
お役に立てば幸いです。
さよなら
Treyの答えは、ページ上のすべてのフラッシュ アイテムに対して非常にうまく機能します。
tb_remove 関数のコード
$('object').each(function(){ this.style.display=this.regDisplay; })
中に入れるべき
j("#TB_window").fadeOut("fast",function(){
...
});
この方法では、フェードアウト後にのみ表示され、すぐには表示されません...
支出者は正しいですが、彼はそれについてあまり説明しませんでした。wmode は、swf を埋め込むときに html に設定される属性であり、透明に設定する必要があります。したがって、AC_RunActiveContent を使用している場合は"wmode", "transparent"
、埋め込み関数に引数として追加するか、swfoject に追加しますso.addVariable("wmode", "transparent");
Flash を DOM の上ではなく「内」に配置するには、次の属性のいずれかを使用する必要があります。
wmode=transparent または wmode=opaque
多くの機能を壊すという欠点があります。
それを行う簡単な方法。IE9 と FIREFOX でのみテストされています。
CSS
#flash {
position: relative; /*or absolute*/
z-index: 0;
}
XHTML
<div id="flash">
<object ...>
<param name="wmode" value="transparent">
<embed ... wmode="transparent">
</object>
</div>
そして、マニの言葉で...それはそれです!
Thickbox.js ファイルでは、これを使用できます。
tb_show 関数を検索し、これを「try」の末尾の「catch」の前に追加します。
$('object').each(function(){
this.regDisplay=this.style.display;
this.style.display='none';
})
と
$('#TB_window object').each(function(){
this.style.display=this.regDisplay;
})
tb_remove 関数を検索し、リターンの前にこれを追加します。
$('object').each(function(){
this.style.display=this.regDisplay;
})