File: load-image.html

package info (click to toggle)
wpewebkit 2.50.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 438,364 kB
  • sloc: cpp: 3,778,495; javascript: 197,888; ansic: 156,951; python: 49,119; asm: 22,003; ruby: 18,540; perl: 16,722; xml: 4,623; yacc: 2,360; sh: 2,096; java: 2,019; lex: 1,327; pascal: 366; makefile: 85
file content (20 lines) | stat: -rw-r--r-- 505 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<html>
<body>
<script>
function canLoadImage(url) {
    return new Promise(resolve => {
        let element = document.createElement("img");
        let complete = event => {
            element.remove();
            resolve(event.type !== "error");
        };
        element.addEventListener("load", complete);
        element.addEventListener("error", complete);
        element.setAttribute("src", url);
        document.body.appendChild(element);
    });
};
</script>
</body>
</html>