国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript – Verwenden Sie Js oder Jq, um zu bestimmen, ob eine Ressource geladen ist
天蓬老師
天蓬老師 2017-05-18 10:57:54
0
4
757

Warten Sie beispielsweise bei einem Bild, bis es geladen ist, also nachdem die Anfrage eingegangen ist, und führen Sie dann einen weiteren Vorgang aus.

Was ist mit anderen Ressourcentypen, z. B. ob die SWF-Datei geladen wird? Ist es dieselbe Methode?

Oder wie überwacht man eine HTTP-Anfrage?

天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見證您的進(jìn)步~~

Antworte allen(4)
洪濤

瀏覽器去加載這些資源或者是異步去發(fā)http請求的話,一般都會提供鉤子函數(shù)

例如,你異步去獲取js代碼:

    const script = document.createElement('script')
    script.src = 'xxxx'
    script.onload = script.onreadystatechange = function () {
        if (!this.readyState || /^(loaded|complete)$/.test(this.readyState)) {
            resolve(window[namespace][name])
            sc.onload = sc.onreadystatechange = null
        }
    }
    document.body.append(script)

你創(chuàng)建的script對象上提供了加載的鉤子函數(shù):onload/onreadystatechange(瀏覽器的兼容性處理),當(dāng)你把script標(biāo)簽插入到DOM中時,瀏覽器另開一個線程去異步加載你需要的js資源,在加載的不同階段:this.readyState對應(yīng)不同的值,這個時候根據(jù)需要設(shè)置你的回調(diào)函數(shù)。這樣就完成了對于一段js代碼異步獲取的監(jiān)控。

PHPzhong

onload事件或者readystatechange事件,但不是所有對象都支持。另外promise應(yīng)該也能吧

PHPzhong

http://stackoverflow.com/ques...

Use SWFObject to embed the SWF, then use the callback function to poll the SWF's PercentLoaded value.

If the value is 0, the SWF has not loaded yet. When it hits 100, the SWF is fully loaded.

Here's a tutorial for polling PercentLoaded, complete with code examples.
阿神

可以考慮ajax或者fetch API

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage