jQuery 对话框顶部的 Flash

发布于 2024-08-06 20:10:55 字数 1115 浏览 6 评论 0原文

我知道很多人都问过这个问题,但我认为我的情况有点不同。

我有一个网站,其中有一些广告,由于 xhtml/html 兼容性问题,这些广告被 Flash 隐藏。但 flash 元素位于我的 jQuery 对话框之上,这并不理想。

一些解决方案建议将 wmode 设置为不透明,但我不能,因为我的广告是输出 flash 元素的脚本。

另一种解决方案建议在显示对话框时隐藏广告。所以我的问题是:有没有一种方法可以将 Flash 内容放在我的 jQuery 对话框后面,同时它们可见并且不更改 Flash 代码?

此致, Lasse Espeholt

更新: 我现在已经用赏金重新回答了这个问题。就目前而言,我隐藏了“显示对话框”上的所有 Flash 广告。但这仍然不是最佳解决方案。因此,我正在寻找一个可以使每个 Flash 动画变得不透明的脚本(jQuery 解决方案最好,但普通的 JavaScript 解决方案也可以)。或者,如果这个问题中没有讨论另一个解决方案,我会很高兴听到它:)

更新 2: 到目前为止,我已经制作了这个脚本:

function opaqueAllFlashMovies() {
    // Embed Flash movies
    $('embed[wmode!="opaque"]').attr('wmode', 'opaque').wrap('<div>');

    // Object flash movies with a wmode param
    $('object[classid$="-444553540000"] parem[wmode]').attr('value', 'opaque');
    // Object flash movies without a wmode param
    $('object[classid$="-444553540000"]').not('param[wmode]').append('<param name=\'wmode\' value=\'opaque\'/>').wrap('<div>');
}

它可以在 FF 和 Chrome 中运行,但不能在 IE 中运行。显然, .append 失败了。有什么想法吗?

I know many have asked this question, but I think my situation is a little bit different.

I have a site where I have some ads which is Flash hidden in a because of xhtml/html compatibility issues. But the flash elements is on top of my jQuery dialogs which is not ideal.

Some solutions have suggested setting wmode to opaque but I can't because my ads are scripts which outputs flash elements.

Another solution suggested hiding ads when a dialog is shown. So my question is: Is there a way to put flash content behind my jQuery dialogs while they are visible and without altering the flash code?

Best regards,
Lasse Espeholt

Update:
I have now reopned the question with a bounty. As for now, I hide every Flash ad on "show dialog". But this is still not an optimal solution. So, I'm looking for a script which can make every Flash animation to opaque (a jQuery solution would be nicest, but a plain JavaScript solution will do). Or if there should be another solution not discussed in this question, I'll be happy to hear about it :)

Update 2:
So far, I have made this script:

function opaqueAllFlashMovies() {
    // Embed Flash movies
    $('embed[wmode!="opaque"]').attr('wmode', 'opaque').wrap('<div>');

    // Object flash movies with a wmode param
    $('object[classid$="-444553540000"] parem[wmode]').attr('value', 'opaque');
    // Object flash movies without a wmode param
    $('object[classid$="-444553540000"]').not('param[wmode]').append('<param name=\'wmode\' value=\'opaque\'/>').wrap('<div>');
}

which works in FF and Chrome but not in IE. Apparently, .append fails. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

筱武穆 2024-08-13 20:10:55

除非将 wmode 设置为不透明(或透明),否则不能将 HTML 放在 Flash 前面。

使用默认的 wmode(“窗口”),Flash Player 接管其区域中的所有渲染和用户交互。因此浏览器无法在该区域显示任何 HTML。 wmode=“opaque”(或 wmode=“transparent”)的作用是禁用此默认行为,并将 Flash Player 区域集成到浏览器通常的渲染和分层等中。

但是您不需要更改任何 Flash 内容来设置 wmode,因为它是在 HTML 中完成的(或通过 SWFObject 或插入 Flash 对象元素的其他脚本),因此如果您可以控制“输出 flash 元素的脚本”您提到的,您可以在那里处理 wmode 设置。

You can't put HTML in front of Flash unless you set wmode to opaque (or transparent).

With the default wmode ("window") the Flash Player takes over all rendering and user interaction in its area. So the browser can't display any HTML in that area. What wmode=" opaque" (or wmode="transparent") does is that it disables this default behavior and kind of integrates the Flash Player area in the browsers usual rendering and layering and such.

But you don't need to alter any Flash content to set wmode, since it is done in the HTML (or via SWFObject or other script that inserts the Flash object element) so if you have control over the "scripts which outputs flash elements" that you mention, you can take care of the wmode setting there.

满意归宿 2024-08-13 20:10:55

我想我有一个解决方案。使用 jquery-ui 对话框,花了好几个小时试图解决这个问题 - 对我来说很有效,

逻辑是如果我不能让 jquery 走在前面,就让所有 flash 内容返回。研究将我带到了这个链接 - 终于它起作用了。

如何以编程方式将所有 的 wmode 设置为不透明?

function makeObjectsOpaque3() {
    var elementToAppend = document.createElement('param');
    elementToAppend.setAttribute('name', 'wmode');
    elementToAppend.setAttribute('value', 'opaque');
    var objects = document.getElementsByTagName('object');
    for(var i = 0; i < objects.length; i++) {
        var newObject = objects[i].cloneNode(true);
        elementToAppend = elementToAppend.cloneNode(true);
        newObject.appendChild(elementToAppend);
        objects[i].parentNode.replaceChild(newObject, objects[i]);
    }
}

window.onload = makeObjectsOpaque3;

if(window.onload) {
    var onLoad = window.onload;
    window.onload = function() {
        onLoad();
        makeObjectsOpaque3();
    };
} else {
    window.onload = makeObjectsOpaque3;
}

i think i have a solution. Using the jquery-ui dialog, Spent hours and hours trying to figure this out - worked for me,

Logic was if i can't make the jquery go front, make all flash content go back. research took me to this link - finally finally it worked.

How do I programmatically set all <object>'s to have the wmode set to opaque?

function makeObjectsOpaque3() {
    var elementToAppend = document.createElement('param');
    elementToAppend.setAttribute('name', 'wmode');
    elementToAppend.setAttribute('value', 'opaque');
    var objects = document.getElementsByTagName('object');
    for(var i = 0; i < objects.length; i++) {
        var newObject = objects[i].cloneNode(true);
        elementToAppend = elementToAppend.cloneNode(true);
        newObject.appendChild(elementToAppend);
        objects[i].parentNode.replaceChild(newObject, objects[i]);
    }
}

window.onload = makeObjectsOpaque3;

and

if(window.onload) {
    var onLoad = window.onload;
    window.onload = function() {
        onLoad();
        makeObjectsOpaque3();
    };
} else {
    window.onload = makeObjectsOpaque3;
}
抚你发端 2024-08-13 20:10:55

在 Flash 加载后,使用 javascript 手动将 wmode 设置为不透明怎么样?

How about manually setting wmode to opaque with javascript after the flash has already loaded?

盛夏已如深秋| 2024-08-13 20:10:55

我刚刚阅读了这篇文章,并尝试在对象标签中添加参数 wmode="opaque" 。它适用于 IE 8。如果我的帖子太晚了,我很抱歉。

I have just read this post and tried to add parameter wmode="opaque" in an object tag. It works for IE 8. I'm sorry if my post is too late.

甜宝宝 2024-08-13 20:10:55

在谷歌上搜索“iframe shim”。
基本上,将 iframe 放在 html 后面会将其置于 Flash 内容之上(忽略 wmode 设置)。

再见

Search google for "iframe shim".
Basically putting an iframe behind the html will bring it over the flash content (ignoring wmode settings).

Bye bye

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文