Little bit of a strange issue.
So, doing a school project, and I'm not supposed to have any errors show up.
But I have one:TypeError: Cannot set property 'volume' of null
at /script.js:3:21
And the weirdest thing is that despite erroring and saying it can't do it, it does do it. I know this because I've tested the output when the line is or isn't commented.
Here's what to look at and in what files:
aboutme.html:
<audio id="CrySil" autoplay loop src="Media/CrySil.mp3" volume></audio>
script.js:
var crysilVolume = document.getElementById("CrySil");
crysilVolume.volume = 0.35;
There isn't much that I see that could be wrong, but if you find anything, let me know, because I have to end with zero errors.
Voters
It seems like you are including the script in pages without a
#CrySil
elementTo fix this, remove the script tag from the pages without the element or check if the element exists
check if element exists
@notGilbert bro, that if statement worked. Problem vaporized.
That was way simpler than I thought.
@AstrumDeorum You can click the checkmark next to his name if it helped to reward him