English 中文(简体)
整个OMM准备执行联合材料
原标题:Executing JS before whole DOM is ready

奥基先生,我就此做了2个职位,但我怎么能把这个职位带给我很少的想法。

因此,我得出结论,如果我们有这样的情况:

<script type="text/javascript" src="somefile.js"></script>
<script type="text/javascript">
func1();
</script>

和 func1()在有些档案中作了界定,在浏览器到达该线时,保证进行操作。

然而,如果我有一页大页(不考虑图像等,仅仅考虑到html),需要几秒钟才能装载,而且要让OM能够准备好(因为我理解,当整个html的法典被装上并放下时,DOM就已经做好了准备),我想执行一些法典,并在总页的其余部分仍在装上的时候,就已经装上该网页?

例如:

<div id="div1">Some div where content will be inserted by the inline javascript below</div>
<script type="text/javascript"> notifyPartLoaded("div1"); </script>

^ 是否存在这样的情况?

最佳回答

我不肯定你的问题是什么,而是确保人力部做好准备的简单方式,就是把 Java的文字放在超文本的底部,就像在封闭的<条码>和斜线上;

<!doctype html>
<html>
    <head>
        <title>some title</title>
        <!-- this script could go toward the bottom too, but it must be before --> 
        <!--   your script if your script relies on it -->
        <script type="text/javascript" src="somefile.js"></script>
    </head>
    <body>  
        <div id="div1">Some div where content will be inserted by the inline javascript below</div>
        <!-- your HTML -->
        <!-- your HTML -->
        <!-- your HTML -->

        <!-- Place your script last -->
        <!-- ...though it would be better to have it in a separate file -->
        <script type="text/javascript"> notifyPartLoaded("div1"); </script>
    </body>
</html>

由于你的法典是所有其他内容之后的,在你的法典最终装满和运行时,它们将存在加以操纵。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签