与html事件属性中的onload方法相反(边缘动画)

时间:2015-08-05 00:39:17

标签: javascript jquery html adobe-edge

html中的onload=""方法停留在"Fires after the page is finished loading" 我需要一个加载<脚本>在页面加载时直接在FIRST。

<!doctype html>
<html>
<head>
<!--Adobe Edge Runtime-->
<script>
var custHtmlRoot="hin-aktuell/Assets/"; 
var script = document.createElement('script'); 
script.type= "text/javascript";
script.src = custHtmlRoot+"edge_includes/edge.6.0.0.min.js";
var head = document.getElementsByTagName('head')[0], done=false;
script.onload = script.onreadystatechange = function(){
    if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
        done=true;
        var opts ={
scaleToFit: "width",
centerStage: "none",
minW: "0px",
maxW: "undefined",
width: "1366px",
height: "768px"
};
        opts.htmlRoot =custHtmlRoot;
        AdobeEdge.loadComposition('hin-aktuell', 'EDGE-2489594', opts,
        {"style":{"${symbolSelector}":{"isStage":"true","rect":["undefined","undefined","1366px","768px"],"fill":["rgba(255,255,255,1)"]}},"dom":{}}, {"dom":{}});      
        script.onload = script.onreadystatechange = null;
        head.removeChild(script);
    }
};
head.appendChild(script);
</script>
<style>
    .edgeLoad-EDGE-2489594 { visibility:hidden; }
</style>
<!--Adobe Edge Runtime End-->

<script> alert(1); </script>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>NC | Allgemeines</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="feed.css">
</head>

这是身体部位

<body> 
    <div id="EdgeStage">
      <div id="Stage" class="EDGE-2489594"></div>
    </div>
    <div id="feeds">            
        <?php
            $html = "";                    
            $url = "http://www.yoursite.com";            
            $xml = simplexml_load_file($url);
                for($i = 0; $i < 1; $i++){
                    $description = $xml->channel->item[$i]->description;
                    preg_match("/<img[^>]+\>/i", $description, $matches);
                    if (isset($matches[0])) {
                        $html .= $matches[0];
                    } else {                                
                        echo "No img";
                    }                            
                }
                echo $html;
        ?>
    <div/>
</body>

现在就是孔文件......

1 个答案:

答案 0 :(得分:1)

页面按顺序执行。如果您将脚本放在<head>中的第一件事,它将在其他任何事情之前执行。请注意,由于其时间安排,页面的<body>将不存在(事实上,<head>中也没有其他内容。)

页面开始加载时没有事件,因为当时不可能有任何代码来处理这样的事件。至少需要先加载<script>个元素。