BUG: The Window_Onload Event Fails to Fire when Page Loads

ID: Q190679


The information in this article applies to:
  • Microsoft Visual InterDev, version 6.0


SYMPTOMS

The window_onload event fails to fire when the page is loaded.


CAUSE

You will see this behavior when either of the following is true:

  • The Scripting Object Model is enabled for the page (the body is enclosed within a form).


  • A DTC is placed before the <BODY> tag.



RESOLUTION

If the Scripting Object Model is enabled or the body is enclosed in a form, use the following workaround:

  1. Change the BODY tag to read <BODY> (remove the language and onload parts of the tag).


  2. Place the contents of your code in a script block designated for the window_onload event.


If a DTC is placed before the <BODY> tag, work around the problem by moving the DTC after the <BODY> tag.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.


MORE INFORMATION

When creating a script block designated for the Window_Onload event, no function() header is required. The following code would bring up an alert when the page is loaded:


   <script language=javascript for=window event=onload>
   <!--
      alert("Page is loaded.");  // sample line (remove)
      // move your code here
   //-->
   </script> 

Steps to Reproduce Behavior

  • Place a DTC before the <BODY> tag on a page.


  • -or-
  • Enable the Scripting Object Model.


Additional query words:

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


Last Reviewed: May 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.