HOWTO: Setting Timeout Period for Script

Last reviewed: October 24, 1997
Article ID: Q175500
The information in this article applies to:
  • Microsoft Internet Explorer (Programming), versions 3.0, 3.01, 3.02, 4.0

SUMMARY

Because some scripts may take an excessive amount of time to run, Internet Explorer 4.0 (IE4) prompts the user to decide whether they would like to continue running the slow script. Some tests and benchmarks may use scripts that take a long time to run and may want to increase the amount of time before the message box appears. In IE4, the script timeout value can be changed on specific client machines by modifying a registry entry.

MORE INFORMATION

There are situations when a Web page contains script that takes an unusually long time to run. If you are scripting an ActiveX control on a Web page to transfer a very large file or do a large database query, this will often cause a significantly long delay. IE3.02 detects the long delay and prompts the user with a dialog box reading the following:

   This page contains a script which is taking an unusually long time to
   finish. To end this script now, click Cancel.

The equivalent message box for IE4 reads:

   A script on this page is causing Internet Explorer to run slowly. If
   it continues to run, your computer may become unresponsive. Do you want
   to abort the script?"

This mechanism allows the user to stop misbehaved script that runs into an endless loop or otherwise is performing slowly.

In IE3.02, this message box can appear on machines running Windows 95. The IE3.02 browser is specifically looking to see if the script thread has pumped any windows messages in the last five seconds. There is no way to override this timeout period for IE3.02. If you are using an ActiveX control with long blocking operations, that ActiveX control should either employ an event mechanism and return control to the caller or call PeekMessage every five seconds to reset the timeout.

As of Internet Explorer 4.0, the timeout is no longer a fixed value based on Windows messages. IE4 now tracks the total number of executed script statements for the current page with the script engine and throws up the timeout dialog box when that value hits a threshold amount.

WARNING: Using Registry Editor incorrectly can cause serious, system-wide problems that may require you to reinstall Windows to correct them. Microsoft cannot guarantee that any problems resulting from the use of Registry Editor can be solved. Use this tool at your own risk.

To change this timeout value in IE4.0, follow these steps:

  1. Using a REGISTRY EDITOR such as Regedt32.exe, open this key:

          HKEY_CURRENT_USER\Software\Microsoft\InternetExplorer\Styles
    

  2. Create a new DWORD value called "MaxScriptStatements" under this key and set the value to the desired number of script statements.

By default the key doesn't exist. If the key has not been added, IE4 defaults to 5,000,000 statements executed as the trigger for the timeout dialog box.

Because the IE4 timeout is based on the number of script statements executed, the timeout dialog box will not display during ActiveX control or database-access delays. Endless loops in script will still be detected.

Keywords          : AXSDKIESripting kbcode
Technology        : kbInetDev
Version           : WINDOWS:3.0,3.01,3.02,4.0
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.