سؤال

أنا عالق على ما يبدو أنه يتنزه مع مؤشر CSS/Z مع لاعب YouTube. في Firefox 3 تحت Windows XP ، ألق نظرة على هذه الصفحة: http://spokenword.org/program/21396 انقر على زر التحصيل ولاحظ أن المنبثقةu003Cdiv style=";text-align:right;direction:rtl"> يبدو تحت لاعب يوتيوب. على المتصفحات الأخرىu003Cdiv style=";text-align:right;direction:rtl"> يظهر في الأعلى. لديها قيمة z-index من 999999. لقد حاولت تعيين z-ondex منu003Cobject> العنصر الذي يحتوي على اللاعب بقيمة أقل ، لكن هذا لم ينجح. أي فكرة عن كيفية ظهور المنبثقة على اللاعب؟

هل كانت مفيدة؟

المحلول

حاول إضافة ملف wmode المعلمة ليكون opaque مثله:

(لاحظ أنه تم تضمينه في على حد سواء أ <param> بطاقة شعار و أ wmode ميزة على <embed> بطاقة شعار.)

<object width='425' height='344'> 
    <param name='movie' value='http://www.youtube.com/v/Wj_JNwNbETA&hl=en&fs=1'> 
    <param name='type' value='application/x-shockwave-flash'> 
    <param name='allowfullscreen' value='true'> 
    <param name='allowscriptaccess' value='always'> 
    <param name="wmode" value="opaque" />
    <embed width='425' height='344'
            src='http://www.youtube.com/v/Wj_JNwNbETA&hl=en&fs=1'
            type='application/x-shockwave-flash'
            allowfullscreen='true'
            allowscriptaccess='always'
            wmode="opaque"
    ></embed> 
    </object> 

نصائح أخرى

على الرغم من أن التوصية من قبل CMS صالحة ، إلا أن هناك تحديثًا مهمًا. إذا كنت ترغب في استخدام "iframe" بدلاً من "التضمين" ، فما عليك سوى إضافة إضافة ?wmode=transparent إلى رابط الفيديو الخاص بك وهذا يفعل السحر. أجد هذا أكثر بساطة ونظيفة.

تحديث, ، فبراير 2014

لقد مر وقت وقد يكون هذا قديمًا.

أبلغ أحدهم ذلك الآن &wmode=transparent يعمل بدلا من ذلك.

لقد وجدت وظيفة 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();    
 });

نحن نستخدم jQuery Flash Plugin لتحويل روابط YouTube إلى أفلام فلاش. في هذه الحالة ، يتم تمرير WMode كخيار من أجل الحصول على فيديو YouTube يظهر أسفل مربع حوار jQuery الذي نفتحه:

$('a[href^="http://www.youtube.com"]').flash(
    { width: nnn, height: nnn, wmode: 'opaque' }
);

لقد لاحظت أن wmode = "غير شفاف" يؤثر بشكل رهيب على استخدام وحدة المعالجة المركزية. Make at on My Notebook 50 ٪ استخدام وحدة المعالجة المركزية (بدون غامضة ~ 8 ٪).
لذا كن حذرا مع هذا الخيار.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top