FIX: Window_Onload Event Does Not Fire on ASP Page

ID: Q190937


The information in this article applies to:


SYMPTOMS

When you Browse an Active Server Pages (ASP) page created using Visual InterDev, the window_onload event does not fire.


CAUSE

You have output in an event handler or navigate method prior to the <BODY> tag being written to the browser.

When you output HTML in server events (for example, by including response.write() statements in the thisPage_onenter event), the browser creates an implied <BODY> tag that overrides the attributes that you may have set on the tag, and the window_onload event is not fired.


RESOLUTION

To avoid this problem, defer all HTML output until the content portion of the page. Use script only to set up state that is used to compose the page. If you need to output HTML prior to the content portion of the page, then you should set the <BODY> tag attributes programmatically using client-side code [for example, window.onload = "return window_onload()"].


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3.

For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed

Additional query words:


Keywords          : kbVisID600 kbVisID600bug kbGrpASP kbVS600sp3fix 
Version           : WINDOWS:6.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 25, 1999