Update Tester.HTML

This commit is contained in:
Dangrainage 2024-04-25 00:13:02 +02:00 committed by GitHub
parent 44add67335
commit 1c69f17558
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,15 +43,10 @@
let listItem = document.createElement('li'); let listItem = document.createElement('li');
let link = document.createElement('a'); let link = document.createElement('a');
link.textContent = `${result.title} (${result.year})`; link.textContent = `${result.title} (${result.year})`;
if (result.link) { // Check if 'link' property is defined link.href = result.link ? result.link : '#'; // If link is not available, set href to '#'
link.href = result.link; // Set link if available
} else {
link.href = '#'; // Set to '#' if link is not available
}
link.onclick = function(event) { link.onclick = function(event) {
event.preventDefault(); // Prevent default link behavior if (!result.link) {
if (result.link) { // Only redirect if 'link' is defined event.preventDefault(); // Prevent default link behavior if link is not available
window.location.href = result.link; // Redirect to the movie page
} }
}; };
listItem.appendChild(link); listItem.appendChild(link);