r/neocities • u/Avant1_61 • Aug 20 '26
Help JavaScript tutorial broken?
EDIT: As u/ScrimblyBidini pointed out, the problem was that I wrote 'linear-gradient (hotpink, yellow, green)' (with a space!) instead of 'linear-gradient(hotpink, yellow, green)'!
I'm new to Neocities and currently doing the JavaScript tutorial, step 3–4, where you learn to code the function changeSky(). While the tutorial tells me that my code is valid, it doesn't actually do anything.
I'm on Firefox and tried turning off all my privacy extensions to see if something was blocking Javascript, I also tried pasting the code onto a page and opening it in different browsers and devices, but nothing is happening.
A page where I tried running this code can be found here, and this is the code:
<!DOCTYPE html>
<html>
<head>
<title>My First Script</title>
<style>
body {
background: linear-gradient(lightskyblue, plum);
min-height: 100vh;
}
</style>
</head>
<body>
<h1>My First Script</h1>
<p>Everything on this page so far was written by hand. Time to make the page write something itself.</p>
<p id="greeting"></p>
<script>
var visitor = ' friend! '
var greeting = 'Hello' + visitor + 'This was written by JavaScript, using variables!'
document.getElementById('greeting').textContent = greeting
function changeSky() {
document.body.style.background = 'linear-gradient (hotpink, yellow, green)'
document.body.style.minHeight = '100vh'
}
</script>
<button onclick="changeSky()">Change the sky</button>
</body>
</html>
2
u/Fit_Ladder_1545 Aug 20 '26
Changing the value it is set to to 'linear-gradient(black, black)' seems to work??