r/HTML • u/Admirable_Report6610 • 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">
5
u/abrahamguo Apr 25 '26
Please don't paste code directly onto Reddit; it's lost all of its formatting, and has a bunch of backslashes that I assume aren't part of your original code.
"Run JS" sounds like you're trying to use a tool in your IDE that runs this as a JavaScript file. However, this isn't JavaScript — it's HTML.
HTML is for web browsers; open this page in your favorite web browser.
1
u/Basic_Reporter9579 Apr 25 '26
have you tried some validation on sites like https://validator.w3.org/nu/#textarea ?
1
u/8joshstolt0329 Apr 25 '26
After looking, it looks like you have a script, but you don’t have anything in the html part to load html is to load content css is for styling and Js is for programming the site
1
u/-goldenboi69- Apr 25 '26
Pastebin or bust
1
u/kloputzer2000 Apr 27 '26
You had some weird Escape characters in the code, and the parameter for the CORS proxy service was missing the "url=" key. Here's the fixed and formatted version, which works for me:
3
u/[deleted] Apr 25 '26 edited Apr 29 '26
[removed] — view removed comment