A problem you have is that you're assuming that the browser is the active window when your page loads. That's simply not the case. A user can start loading your page and switch windows to something else by the time your page loads and starts executing.
You cannot use the "current window" to look for controls. Why are you not using the normal VB6 method of:
TextBox1.SetFocus