admin管理员组文章数量:1356385
Do you know if it is possible to make sure that a JavaScript script site is ran first in a web page?
For the context, I'm trying to tag every span
before another library (just like cufon) kicks in and messes with the original content. Since it's not possible to use onLoad()
on spans, it's the only way I can see to do that on the client side.
Do you know if it is possible to make sure that a JavaScript script site is ran first in a web page?
For the context, I'm trying to tag every span
before another library (just like cufon) kicks in and messes with the original content. Since it's not possible to use onLoad()
on spans, it's the only way I can see to do that on the client side.
-
Have you tried including the script just after where your
<span>
s are in your HTML, or anywhere before your other scripts? – Bojangles Commented Jun 8, 2012 at 10:51
2 Answers
Reset to default 6Order of precedence is determined by the order in which things load.
- Head tag scripts (in the order they are listed)
- Scripts & other event attributes in the order they appear in the code.
- Body onLoad
I did have #2 & #3 mixed up - to clarify the body onLoad event fires after the entire body (scripts included) loads
Also, scripts altering <span>
tags will have no effect if placed in the head tag (unless they are a function) since the script runs when it is loaded, and when the head loads, the body & span tags haven't loaded yet.
Place <script>
tag in page source after content that you need to modify, but before any other scripts. Scripts run in same order that their tags appear on page.
本文标签: htmlHow to run a javascript script before the other onesStack Overflow
版权声明:本文标题:html - How to run a javascript script before the other ones? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744060780a2584083.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论