Daily Comicstrips

無料
よって pnpninja | 更新済み a month ago | Entertainment
人気

0.2 / 10

レイテンシー

131ms

サービスレベル

100%

Health Check

N/A

すべてのディスカッションに戻る

substitute with pure javascript

Rapid account: Powlwoq
powlwoq
2 years ago
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Daily Comicstrip</title>
    <script type="application/javascript">
        function loadComicImage(comicType) {
            const baseUrl = "https://www.arcamax.com/thefunnies/";
            const xhr = new XMLHttpRequest();
            var remoteUrl;
            xhr.open("GET", baseUrl + comicType);
            xhr.send(null);
            xhr.onreadystatechange = function(){
                if(xhr.readyState === 4){
                    const remotedoc = new DOMParser().parseFromString(xhr.responseText.replace(/<script(.|\s)*?\/script>/g, ''), 'text/html');
                    remoteUrl = remotedoc.getElementById("comic-zoom").getAttribute("data-zoom-image");
                    console.log("remoteUrl: " + remoteUrl)
                    var image = document.getElementById("comic");
                    image.src = remoteUrl;
                }
            };
        }
        
    </script>
</head>
<body>
<p align="center">
    <button onclick="loadComicImage('dilbert')">ENGAGE</button>
    <br>

    <img id="comic" src="XXX" title="comicstrip of the day"/>
</p>
</body>
</html>

ディスカッションに参加しましょう-以下にコメントを追加してください:

ログイン/サインアップして新しいコメントを投稿