0

次のコードは、Webページの読み込み時にfloat-in divを起動しますが、起動するまでに60秒の遅延が必要です。誰か助けてもらえますか?フロートインdivのデモはwww.bizassist.co.zaで見ることができます。

ありがとうございました。

コード:

var timer;
var h = -450;   
var w = 500;    
var t = 150;

function startAp() {
    setLeft();
    showAp();
}

function hideAp() { 
    if (document.layers) {
        document.layers.pa.visibility = 'hide';
    } else if (document.all) {
        document.all.pa.style.visibility = 'hidden';
    } else if (document.getElementById) {     
        document.getElementById("pa").style.visibility = 'hidden';
    }
}

function showAp() { 
    state=typeof tPos;

    if(state=='undefined') {
        tPos = h;
    }

    if(tPos < t) { 
        tPos+=25;
        if (document.layers) {
            document.layers.pa.top = tPos+"px";
        } else if (document.all) {
            document.all.pa.style.top = tPos+"px";
        } else if (document.getElementById) { 
            document.getElementById("pa").style.top = tPos+"px";
        }
    }

    if(timer!=null) clearInterval(timer);
    timer = setTimeout("showAp()",30);
}

function getoPos() {
    if (document.layers) {
        alert(document.layers.pa.top);
    } else if (document.all) {
        alert(document.all.pa.style.top);
    } else if (document.getElementById) { 
        alert(document.getElementById("pa").style.top);
    }
}

function setLeft() {
    if (document.layers) { 
        document.layers.pa.left = ((window.innerWidth / 2) - (w / 2))+"px";
    } else if (document.all) { 
        document.all.pa.style.left = ((document.body.offsetWidth / 2) - (w / 2))+"px";
    } else if (document.getElementById) {
        document.getElementById("pa").style.left = ((window.innerWidth / 2) - (w / 2)) + "px";
    }
}
4

1 に答える 1

0

関数を使用して、setTimeout少し遅れて関数を実行します。例えば

setTimout(showApp, 6000) // time is in milliseconds
于 2012-02-05T20:59:26.123 に答える