Webmaster общности: Predpriemach.com | SearchEngines.bg

    Javascript – Бавно зареждане на страница

    Работи само на Internet Explorer но си заслужава да се види.
    Този код го гепих от един сайт, ама вече незнам кой беше точно.

    Ето как се постига:
    Създавате един файл с име
    functions.js

    function roll() {
    var img, sh, sn, sd
    for (var i = 0; (img = document.images[i]); i++) {
    if (img.getAttribute) {
    
    sn = img.getAttribute("src");
    sh = img.getAttribute("hsrc");
    sd = img.getAttribute("dsrc");
    
    if (sn != "" && sn != null) {
    img.n = new Image();
    img.n.src = img.src;
    
    if (sh != "" && sh != null) {
    img.h = new Image();
    img.h.src = sh;
    img.onmouseover = soopaSwapOn
    img.onmouseout = soopaSwapOff
    }
    
    if (sd != "" && sd != null) {
    img.d = new Image();
    img.d.src = sd;
    img.onmousedown = soopaSwapDown
    }
    }
    }
    }
    }
    
    function soopaSwapOn() {
    this.src = this.h.src;
    }
    
    function soopaSwapOff() {
    this.src = this.n.src;
    }
    
    function soopaSwapDown() {
    this.src = this.d.src;
    this.temp = typeof(document.onmouseup) != 'undefined' && typeof(document.onmouseup) != 'unknown' ? document.onmouseup : "";
    soopaSwapUp.img = this;
    document.onmouseup = soopaSwapUp;
    }
    
    function soopaSwapUp() {
    var ths = soopaSwapUp.img;
    ths.src = ths.n.src;
    if (ths.temp) document.onmouseup = ths.temp;
    }
    
    function CloseJacket() {
    window.opener=parent;
    window.close();
    }
    
    function fadeIn() {
    oDiv.style.filter="blendTrans(duration=2)";
    if (oDiv.filters.blendTrans.status != 2) {
    oDiv.filters.blendTrans.apply();
    oDiv.style.visibility="visible";
    oDiv.filters.blendTrans.play();
    }
    }
    
    function fadeOut() {
    oDiv.style.filter="blendTrans(duration=2)";
    if (oDiv.filters.blendTrans.status != 2) {
    oDiv.filters.blendTrans.apply();
    oDiv.style.visibility="hidden";
    oDiv.filters.blendTrans.play();
    }
    }
    
    function fadeIn2() {
    oDiv2.style.filter="blendTrans(duration=2)";
    if (oDiv2.filters.blendTrans.status != 2) {
    oDiv2.filters.blendTrans.apply();
    oDiv2.style.visibility="visible";
    oDiv2.filters.blendTrans.play();
    }
    }
    
    function fadeOut2() {
    oDiv2.style.filter="blendTrans(duration=2)";
    if (oDiv2.filters.blendTrans.status != 2) {
    oDiv2.filters.blendTrans.apply();
    oDiv2.style.visibility="hidden";
    oDiv2.filters.blendTrans.play();
    }
    }
    
    
    После добавяте в вашата станица следния код:
    
    Между <head> и </head> слагате това:
    
    <script language="javaScript" src="functions.js"></script>
    
    
    После в <body>:
    
    <body onload="fadeIn()" >
    <div style="width:100%;visibility:hidden" ID="oDiv">
    

    И готово.
    Незабравяите, че тази страница няма да работи на нито един браузер освен IE .

    Подготвено специално за http://web-tourist.net

    Оставете коментар