PRB: Functions Are Automatically Invoked When SOM Is Enabled (197967)



The information in this article applies to:

  • Microsoft Visual InterDev 6.0

This article was previously published under Q197967

SYMPTOMS

When you have the Scripting Object Model (SOM) enabled on your Active Server Pages (ASP) page, any JavaScript functions following the naming convention "xxxx_ctor" or "xxxx_dtor" are automatically executed instead of being called programmatically.

CAUSE

The SOM uses the 'RuntimeObject' method to find the all the constructors and destructors of script objects. Under the current implementation, in the object construction phase, the method RuntimeObject walks through the ASP page and finds all members that match the pattern *_ctor and adds them to the constructor collection ctor. It then invokes all the constructor functions. In the object destruction phase, the RuntimeObject method walks through the ASP page and finds all members that match the pattern *_dtor and adds them to the destructor collection dtor. It then invokes all the destructor functions.

Because of this implementation, any JavaScript functions with the name xxxx_ctor or xxxx_dtor are invoked automatically even if they are not constructors or destructors for script objects.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Active Server Page (ASP) page.
  2. Enable the Scripting Object Model for the page.
  3. Add the following code to the page:
          <SCRIPT LANGUAGE=javascript RUNAT=Server>
          function dummy_ctor()
          {
              Response.Write ("a fake constructor");
          }
          function dummy_dtor()
          {
             Response.Write ("a fake destructor");
          }
          </script>
    						
  4. View the ASP page. The two functions above are not explicitly called, but results are written to the browser.

Modification Type:MajorLast Reviewed:4/22/2001
Keywords:kbprb kbScript KB197967