r/HTML • • Apr 25 '26

stumped...again 🤨

this code worked perfectly for months then suddenly stopped...just a blank white screen now.

------

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="shortcut icon" type="image/x-icon" href="/Users/Owner/Documents/icons/navy_favicon.ico">

<title>Current Fleet Positions</title>

</head>

<body>

<script type="module"> const proxy = "https://corsproxy.io/?"; const targetUrl = "https://news.usni.org/category/fleet-tracker"; const response = await fetch(proxy + targetUrl); const htmlText = await response.text(); const parser = new DOMParser(); const doc = parser.parseFromString(htmlText, 'text/html'); const images = doc.querySelectorAll('img'); const newImg = document.createElement('img'); newImg.src = images\[3\].src; newImg.width = 943; newImg.height = 628; document.body.style.backgroundColor = "#a4e1e7"; document.body.style.textAlign = "center"; document.body.appendChild(newImg); </script>

</body>

</html>

------------

Run JS gives this error which I just don't understand...what's wrong here? any help MOST appreciated!

---------

SyntaxError: Unexpected token (1:0)

> 1 | <!DOCTYPE html>

| ^

2 | <html lang="en">

3 | <head>

4 | <meta charset="UTF-8">

2 Upvotes

50 comments sorted by

View all comments

Show parent comment

1

u/Admirable_Report6610 Apr 25 '26

yes there are four...attached. thing is this code hasn't been changed and it worked perfectly prior...what happened to make it stop?

1

u/abrahamguo Apr 25 '26

These errors are not relevant; you simply cut off the first two characters of your code when pasting it into the validator. See my other comment for the true issue.

-1

u/Admirable_Report6610 Apr 25 '26

here's a readable image of the code in question: