-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
27 lines (23 loc) · 879 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const imageUrlInput = document.getElementById('image-url');
const checkButton = document.getElementById('check-button');
const image = document.getElementById('image');
const imageStatus = document.getElementById('image-status');
checkButton.addEventListener('click', () => {
const url = imageUrlInput.value.trim();
if (!url) {
return alert('Please enter a valid image URL.');
}
image.src = '';
imageStatus.textContent = 'Checking...';
fetch(url)
.then(response => response.blob())
.then(blob => {
const imageUrl = URL.createObjectURL(blob);
image.src = imageUrl;
imageStatus.textContent = 'Image loaded successfully!';
})
.catch(error => {
image.src = '';
imageStatus.textContent = `Error: ${error.message}`;
});
});