<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>
Join in the discussion - add comment below: