如何在DOM准备好之前加载jQuery [英] How to load jQuery before DOM is ready

查看:180
本文介绍了如何在DOM准备好之前加载jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在DOM准备好之前加载一些jQuery代码。我想在DOM加载时制作一个Flash文件转换器。我将要使用这样的东西,但Flash在DOM加载之前被启动。

  jQuery(document).ready(function ){
jQuery('object:not(:has(wmode))')。each(function(){
jQuery(this).attr('wmode','transparent');
jQuery(this).prepend('< param name =wmodevalue =transparent>');
jQuery(this).children('embed')。attr('wmode' 'transparent');
});
});

有关如何做的任何想法?



< hr>

编辑



嘿,谢谢你的帮助,基本上,Flash的内容来自我们的广告经理,愚蠢的,不允许直接编辑HTML,为了添加所需的wmode归因于特定的标签...



所以Javascript是我唯一的选择..

解决方案

ready()是您可以安全访问任意DOM元素。



您可以在声明脚本 >对象标签:应该可以使用,您将可以访问对象元素。



但是,我不认为这样会帮助你:据我所知,Flash不会接受JavaScript侧的更改 wmode 参数。



您必须将 wmode.transparent HTML,或在加载DOM时动态创建Flash电影。


I want to load some jQuery code before the DOM is ready. I want to make a flash file transparant as the DOM loads. I was going to use something like this but Flash is initilized before the DOM loads.

jQuery(document).ready(function(){
    jQuery('object:not(:has(wmode))').each(function(){
        jQuery(this).attr('wmode', 'transparent');
        jQuery(this).prepend('<param name="wmode" value="transparent">');
        jQuery(this).children('embed').attr('wmode', 'transparent');
    });
});

Any ideas on how to do this?


EDIT

Hey guys, thanks for the help, Basically, The flash content is coming from our Advertisement Manager, which stupidly enough, doesn't allow direct editing of the HTML, as to add the required wmode attributed into the specific tags...

So Javascript is my only option...

解决方案

ready() is the earliest point at which you can safely access arbitrary DOM elements.

You could put a script block directly after you declare the object tag: That should work, you will have access to the object element.

However, I don't think even that will help you: As far as I know, Flash won't accept a JavaScript-side changing of the wmode parameter anyway.

You would have to put wmode.transparent into the HTML, or create the Flash movies dynamically when the DOM is loaded.

这篇关于如何在DOM准备好之前加载jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆