10

我需要将wmode任意 Flash 对象从外部 js 文件更改为透明,以确保它们不会在不使用 Jquery 或类似库的情况下隐藏菜单。

在 FF 我使用getElementsByTagName("embed")并设置属性。它似乎运作良好。

具体来说,我在 IE7 中objectswfObject库设置时遇到问题。

swfObject在 iE7 中创建以下代码:

<OBJECT id=mymovie height=400 width=134 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>
        <PARAM NAME="_cx" VALUE="3545">
        <PARAM NAME="_cy" VALUE="10583">
        <PARAM NAME="FlashVars" VALUE="">
        <PARAM NAME="Movie" VALUE="imgs/site/tower.swf">
        <PARAM NAME="Src" VALUE="imgs/site/tower.swf">
        <PARAM NAME="WMode" VALUE="Window">
        <PARAM NAME="Play" VALUE="0">
        <PARAM NAME="Loop" VALUE="-1">
        <PARAM NAME="Quality" VALUE="High">
        <PARAM NAME="SAlign" VALUE="">
        <PARAM NAME="Menu" VALUE="-1">
        <PARAM NAME="Base" VALUE="">
        <PARAM NAME="AllowScriptAccess" VALUE="">
        <PARAM NAME="Scale" VALUE="ShowAll">
        <PARAM NAME="DeviceFont" VALUE="0">
        <PARAM NAME="EmbedMovie" VALUE="0">
        <PARAM NAME="BGColor" VALUE="FFFFFF">
        <PARAM NAME="SWRemote" VALUE="">
        <PARAM NAME="MovieData" VALUE="">
        <PARAM NAME="SeamlessTabbing" VALUE="1">
        <PARAM NAME="Profile" VALUE="0">
        <PARAM NAME="ProfileAddress" VALUE="">
        <PARAM NAME="ProfilePort" VALUE="0">
        <PARAM NAME="AllowNetworking" VALUE="all">
        <PARAM NAME="AllowFullScreen" VALUE="false">
</OBJECT>

我尝试了所有可能的方法来设置wmodetransparent让闪光灯在没有成功的情况下不隐藏浮动对象,包括但不限于:

  1. 搜索OBJECT并将其更改PARAM wmodetransparent.
  2. Object设置( wmode=transparent)的属性
  3. 调用object'SetValue函数

似乎没有一个工作。尽管 wmode 似乎改变了 Flash 仍然隐藏了其他具有高z-index. 我在这里想念什么?

4

5 回答 5

10

我用这个小技巧成功了:

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

它有效地重绘了 flash 对象,对我有用。

于 2009-12-27T14:12:24.337 回答
3

一般来说,Cirday 的解决方案是正确的。这是一个非 jQuery 版本,适用于 IE、FF 和 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 array
var 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){
        // IE
        var 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]);
    }
}
于 2011-12-22T18:12:00.160 回答
2

当您使用 SWFObject 包含 flash 时,embedSWF 方法中应该有一个名为“params”的参数。你像这样将一个对象传递给它:

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

更多在这里

于 2009-02-10T22:24:21.823 回答
1

需要重新发布 Flash 电影以更改 wmode 参数是不正确的 - 这是一个神话:

http://www.communitymx.com/content/article.cfm?cid=E5141

我有同样的菜单问题,我需要一些代码来将 wmode 参数添加到 javascript 调用的任何 flash 对象中。

我认为原始帖子与此有关,但我不确定从哪里开始并且需要更多信息。

于 2009-07-25T14:03:05.613 回答
0

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

于 2009-02-11T09:43:49.087 回答