I'm trying to use IE ActiveX control to update Autohotkey GUI dynamically, but encountering weird behavior. Please help.

```
; ie-refresh.ahk on Autohotkey 1.1.24
global WB

Gui, Font, s9 cBlack, Tahoma
Gui, Add, Text, , % "Click button to see html content."
Gui, Add, ActiveX, xm w120 h30 vWB, Shell.Explorer
Gui, Add, Button, xm gBtnClicked, % "Update html text"
Gui Show
return

BtnClicked()
{
    html_tmpl = 
( Ltrim Join
<!DOCTYPE html>
<html>
    <head>
        <style>
            body { 
                margin: 0px;
                color: red;
            }
        </style>
    </head>
    <body>
Count: {}
    </body>
</html>
)
    static snum := 0
    snum++

    html_code := Format(html_tmpl, snum)

    WB.Navigate("about:blank")
    WB.document.write(html_code)

}

GuiEscape:
GuiClose:
ExitApp

```

When I click the button, the IE content updates, **but it only updates twice**.

[![IE ActiveX updating](https://i.stack.imgur.com/uM52d.png)](https://i.stack.imgur.com/uM52d.png)

On third button click, IE content area almost certainly **shows as blank**. 

[![enter image description here](https://i.stack.imgur.com/GHoYV.png)](https://i.stack.imgur.com/GHoYV.png)

Keep clicking the button, the red text appears intermittently and randomly, rougly one out of ten clicks.

So what's wrong with my code?