# Dump "document.write" ASAP

To get some random info quickly on your webpage I used `document.write` until I came across this article here from Mozilla: [TL;DR](https://developer.mozilla.org/en-US/docs/Web/API/Document/write). Then I realized I had to get rid of this behavior quickly and find another way to achieve the same, and here's one way of doing so.

**This is how I did it in the "old" days:**

```bash
<!--random refresh number generator-->
<div class="fixedRandom">
    <script>
        document.write("refresh-id:");
        document.write(Math.floor(Math.random() * (1000000000000000000 + 1)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."));
    </script>
</div>
```

To give some context, the result is a unique generated ID every time the webpage refreshes, which looks like this:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1673047366565/74538d86-cba3-4304-8b6e-31d6081801a7.png align="center")

It's a very small almost hidden line, 14pts in a grey color, with a fixed font.

# "innerHTML" To The Rescue

To get the same result with a different approach I used `innerHTML` TL;DR [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML).

**So this is how I do it now:**

```bash
<!--random refresh number generator-->
<div class="fixedRandom" id="refreshId">
    <script>
        document.getElementById("refreshId").innerHTML = "refreshId:" + Math.floor(Math.random() * (1000000000000000000 + 1)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
    </script>
</div>
```

**With this new approach, the result is identical.**
