Javascript DOM ready without an entire framework

给你一囗甜甜゛ 提交于 2019-11-27 13:13:10

问题


Does anyone know of a good javascript DOM ready library that I can use without loading an entire framework? I found one on google code that seems to work, but the library was posted in 2008 and I can't find any confirmation on up-to-date cross browser support.


回答1:


David Mark's "My Library" has a "DOM ready" functionality:

http://www.cinsoft.net/mylib.html

David is avid anti-framework, anti-bad-javascript-practice so it should be good quality code.




回答2:


Just do this right before the closing body tag:

<html>
<script>
function runAfterLoad() {
}
... lots of stuff
</script>
<body>

... lots of stuff

<script>runAfterLoad();</script></body>
</html>



回答3:


Checkout Dean Edwards' base2. It contains a minimal amount of code necessary to patch up browser differences and provide nice consistent interface as per the standards. The gzipped version is only 6k.




回答4:


Use ded's domready




回答5:


It seems that the safest bet is indeed to use a javascript framework. I was able to find some small DOMready libraries - but nothing written recently or claiming to be confirmed working with the most current browser releases.




回答6:


please check out this simple function dom ready function

it has been tested in ie 8 , firefox, chrome and safari .

and check this answer javascript domready?



来源:https://stackoverflow.com/questions/2732171/javascript-dom-ready-without-an-entire-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!