[This is preliminary documentation and subject to change]
Enables access to external libraries and facilitates direct reference of entities contained within specified namespaces.
import namespace
namespace
Required. Name of a NGWS namespace being imported.
The import statement creates a property of the global object with the name supplied as namespace, and initializes it to contain the object that corresponds to the namespace being imported. Any properties created using the import statement cannot be assigned to, deleted, or enumerated.
It is important to note that using the import statement does not locate or load a namespace, the host must provide this functionality. For example, ASP+ uses a directive that appears as follows:
<%@ import namespace = "mydll" assembly = "mydll.dll"%>
The exception to this rule is a namespace declared in Jscript using the package mechanism; if the package is in the same source file (or is included in the source file) in which it is imported, the host does not need to load it.
Once a namespace has been imported, JScript searches for identifiers within the namespace and adds them to the global scope. All classes that are scoped at the highest level of a namespace are available without being fully qualified. Embedded namespaces, or classes nested inside a namespace within an imported namespace, must be fully qualified, including the imported namespace's name.
The following example imports a namespace (Acme) containing a single class (Gadget) along with another namespace (Widget) that includes a single class (Sprocket):
// The following line in not legal because, even though the reference
// to Gadget is fully qualified, the Acme namespace has not yet
// been imported.
var g1 = new Acme.Gadget();
// Import the Acme namespace
import Acme
// The following two lines are legal and do exactly the same thing.
var g2 = new Acme.Gadget;
var g3 = new Gadget;
// The following is legal because Acme is in the namespace.
var s1 = new Acme.Widget.Sprocket();
// The following two lines are not legal because the Widget
// namespace has not yet been added.
var s2 = new Sprocket();
var s3 = new Widget.Sprocket();
// Import the Acme.Widget namespace.
import Acme.Widget;
// Now all the following will work.
var g4 = new Gadget();
var g5 = new Acme.Gadget();
var s4 = new Sprocket();
var s5 = new Acme.Widget.Sprocket();
var s6 = new Widget.Sprocket();