Question re: targeting objects with getElementById

I’m referencing the object or object handle incorrectly, is that what ‘this.’ is called ?
I put together a super simple page demonstrating my ravings and my question using spinning colored boxes.
LINK (see source)

#greenbox and #greybox essentially have the same code.
One uses this. and the other uses the var orangehandle

Many thanks in advance

The problem is you’re trying to get the element by its ID… before it’s been created.

The absolute quickest fix is to just put the <script> tag after the #orangebox element:

<div id="orangebox"></div>

<script type="text/javascript">
    var orangevar = document.getElementById("orangebox");

thank you!
TIL something about parsing