jQuery oembed 插件 z-index 问题

发布于 2024-08-27 21:36:42 字数 186 浏览 5 评论 0原文

我正在使用 jQuery oembed 插件来显示来自 Vimeo feed 的视频。

唯一的问题是它们显示在我的导航菜单的顶部。我尝试过设置菜单的 z-index,但这没有什么区别。

一个常见的建议似乎是将 wmode 参数设置为透明或不透明。但是,将其作为参数传递给 oembed 函数没有什么区别。

谢谢

I'm using the jQuery oembed plugin to display videos from a Vimeo feed.

The only problem is they display over the top of my navigation menu. I have tried setting the z-index of the menu but this makes no difference.

A common suggestion seems to be to set the wmode parameter to transparent or opaque. However, passing this as a parameter to the oembed function makes no difference.

Thanks

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

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

发布评论

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

评论(3

伴随着你 2024-09-03 21:36:42

您可以使用自己的回调函数来处理返回的代码,因此可以在插入之前对其进行修改。

这是一个有点丑陋的东西,但我希望有人可以改进:

$(".oembed").oembed(null, null, function(container, oembed) {
        if (oembed == null)
            return; 
        if (oembed.type == "video" && oembed.code != null) {
            if (oembed.code.indexOf("wmode") < 0) {
                oembed.code = oembed.code.replace("<embed ", "<param name=\"wmode\" value=\"transparent\"></param>\n<embed ");
                oembed.code = oembed.code.replace("<embed ", "<embed wmode=\"transparent\"");                                        
            }
        }
        $.fn.oembed.insertCode(container, "replace", oembed);
    });

问候,

理查德。

You can use your own callback function to process the returned code, so it is possible to modify it before inserting it.

This is something a little ugly that works but I hope someone can improve:

$(".oembed").oembed(null, null, function(container, oembed) {
        if (oembed == null)
            return; 
        if (oembed.type == "video" && oembed.code != null) {
            if (oembed.code.indexOf("wmode") < 0) {
                oembed.code = oembed.code.replace("<embed ", "<param name=\"wmode\" value=\"transparent\"></param>\n<embed ");
                oembed.code = oembed.code.replace("<embed ", "<embed wmode=\"transparent\"");                                        
            }
        }
        $.fn.oembed.insertCode(container, "replace", oembed);
    });

Regards,

Richard.

时间海 2024-09-03 21:36:42

我遇到了同样的问题,这是我的解决方案:

    var fixZindex = function(){

        $(".oembed").css('z-index','1').css('position','relative');
        $("object").css('z-index','1').css('position','relative');
        $("embed").css('z-index','1').css('position','relative');

        var elements = document.getElementsByTagName('embed');
        for(var i=0; i< elements.length; i++){

                elements[i].setAttribute("wmode","transparent");

                var para = document.createElement("param");
                para.setAttribute("name","wmode");
                para.setAttribute("value","transparent");

                elements[i].parentNode.appendChild(para)

        }

    }

    $(document).ready(function() {
        $(".oembed").oembed(null,
            {
            embedMethod: "append",
            maxWidth: 500
            });

        setTimeout('fixZindex()',1000);

    });

我对 js/jquery 的混合表示歉意。无论如何,我都不是 jquery 专家,所以如果有人可以直接用 jquery 重新编码该解决方案,那就太棒了。

I had the same issue and this is my solution:

    var fixZindex = function(){

        $(".oembed").css('z-index','1').css('position','relative');
        $("object").css('z-index','1').css('position','relative');
        $("embed").css('z-index','1').css('position','relative');

        var elements = document.getElementsByTagName('embed');
        for(var i=0; i< elements.length; i++){

                elements[i].setAttribute("wmode","transparent");

                var para = document.createElement("param");
                para.setAttribute("name","wmode");
                para.setAttribute("value","transparent");

                elements[i].parentNode.appendChild(para)

        }

    }

    $(document).ready(function() {
        $(".oembed").oembed(null,
            {
            embedMethod: "append",
            maxWidth: 500
            });

        setTimeout('fixZindex()',1000);

    });

I apologize for the mix of js/jquery. I'm not a jquery expert by any means so if someone can recode that solution in straight jquery that'd be rad.

陌生 2024-09-03 21:36:42

您好,感谢您的代码共享。

我在 'var code = ----- ;' 之前添加了以下内容
到 jquery.oembed.js 中的 getVideo... 函数体,它可以工作。只需相应修改变量即可。

if (oembed.code.indexOf("wmode") < 0) {
oembed.code = oembed.code.replace("\n

简单又容易。

谢谢,
阿尤布

Hi thanks for code sharing.

I have added the following just before the 'var code = ----- ;'
to the getVideo... function body in jquery.oembed.js, and it works. just modified the variables accordingly.

if (oembed.code.indexOf("wmode") < 0) {
oembed.code = oembed.code.replace("\n
}

Its easy and simple.

Thanks,
Ayub

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