0

how can i show a < script > in html before the page load the content?

<script>
    function startTime() {
        var today=new Date();
        var h=today.getHours();
        var m=today.getMinutes();
        var s=today.getSeconds();
        m = checkTime(m);
        s = checkTime(s);
        document.getElementById('uhrzeit').innerHTML = h+":"+m+":"+s;
        var t = setTimeout(function(){startTime()},500);
    }   

    function checkTime(i) {
        if (i<10) {i = "0" + i};  // add zero in front of numbers < 10
        return i;
    }
</script>

the first one just shows the time of day... more important is the second part. At the moment the website is loading the content and shows me the Edge-Animate animation after the content is complete loaded. And you may mention it sucks that the animation comes after paged is loaded...

<!--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: "none",
            centerStage: "none",
            minW: "0px",
            maxW: "undefined",
            width: "100%",
            height: "100%"
        };
        opts.htmlRoot =custHtmlRoot;
        AdobeEdge.loadComposition('hin-aktuell', 'EDGE-2489594', opts,
        {"dom":{}}, {"dom":{}});        
        script.onload = script.onreadystatechange = null;
        head.removeChild(script);
    }
};
    head.appendChild(script);
</script>
isherwood
  • 58,414
  • 16
  • 114
  • 157
Bob
  • 83
  • 1
  • 1
  • 7
  • Really not clear what you are asking. Elements have to exist before you can animate them – charlietfl Aug 04 '15 at 13:38
  • i have a page and an image as a content... i want to have an edge animate animation before the image shows up... so first animation than load image – Bob Aug 04 '15 at 13:40
  • The solution is to hide the image in your markup or CSS, and then show it in your script. It's not a matter of load order. – isherwood Aug 04 '15 at 13:55
  • so i have to hide the div where the image is. Change the css of this div and say it have to show up after some seconds? – Bob Aug 04 '15 at 13:59
  • Yes. I haven't used AdobeEdge but right after the animation completes, include image.show() otherwise, write a setTimeout to show it. – GobSmack Aug 04 '15 at 14:31
  • Doesn't work... i'm not sure what i am doing wrong... – Bob Aug 04 '15 at 14:35
  • Instead of doing removeChild on scripts, I think you should use callback approach suggested here: http://stackoverflow.com/questions/5187968/how-should-i-call-3-functions-in-order-to-execute-them-one-after-the-other – GobSmack Aug 04 '15 at 14:43
  • If i have understood it correct, you want animation to happen first and then the start time or load image right? – GobSmack Aug 04 '15 at 14:44

0 Answers0