[toc]
启用和返回对自动化对象的引用。
此对象仅用于实例化自动化对象,且此对象没有成员。
**警告**
> 此对象为 Microsoft 扩展,仅在 Internet Explorer 中受支持,在 Windows 8.x 应用商店应用中不受支持。
## 语法
~~~
newObj = new ActiveXObject(servername.typename[, location])
~~~
## 参数
### newObj
必选。 ActiveXObject 分配到的变量名称。
### servername
必选。 提供对象的应用程序的名称。
### typename
必选。 要创建的对象的类型或类。
### location
可选。 要在其中创建对象的网络服务器的名称。
## 备注
自动化服务器至少提供一种对象。 例如,字处理应用程序可能会提供应用程序对象、文档对象和工具栏对象。
你可以在 HKEY_CLASSES_ROOT 注册表项中标识宿主 PC 上的 servername.typename 值。 例如,下面是可在此处找到的几个值示例,具体取决于安装的程序:
- Excel.Application
- Excel.Chart
- Scripting.FileSystemObject
- WScript.Shell
- Word.Document
- System_CAPS_important
## 重要事项
ActiveX 对象可能存在安全问题。 若要使用 ActiveXObject,你可能需要在相关安全区域的 Internet Explorer 中调整安全设置。 例如,对于本地 Intranet 区域,通常需要将自定义设置更改为“对没有标记为安全的 ActiveX 控件进行初始化和脚本运行”。
如果没有可用的自动化对象的参考文档,则要标识可以在代码中使用的自动化对象的成员,你可能需要使用 COM 对象浏览器,例如 OLE/COM 对象查看器。
若要创建自动化对象,请将新的 ActiveXObject 分配给对象变量:
~~~
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
~~~
此代码启动创建对象的应用程序(在此示例中,为 Microsoft Excel 工作表)。 在创建某个对象后,可在代码中使用已定义的对象变量引用该对象。 在下面的示例中,使用对象变量 ExcelSheet 和其他 Excel 对象(包括应用程序对象和 ActiveSheet.Cells 集合)来访问新对象的属性和方法。
~~~
// Make Excel visible through the Application object.
ExcelSheet.Application.Visible = true;
// Place some text in the first cell of the sheet.
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
// Save the sheet.
ExcelSheet.SaveAs("C:\\TEST.XLS");
// Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Quit();
~~~
## 要求
在以下文档模式中受支持:Quirks、Internet Explorer 6 标准、Internet Explorer 7 标准、Internet Explorer 8 标准、Internet Explorer 9 标准、Internet Explorer 10 标准和 Internet Explorer 11 标准。 在 Windows 8.x 应用商店应用中不受支持。
**说明**
> Internet Explorer 9 标准模式、Internet Explorer 10 标准模式、Internet Explorer 11 标准模式和 Windows 应用商店应用或更高版本不支持在远程服务器上创建 ActiveXObject。
- ActiveXObject对象
- Array对象
- constructor属性
- length属性
- prototype属性
- Array.from函数
- Array.isArray函数
- Array.of函数
- concat方法
- entries方法
- every方法
- fill方法
- filter方法
- findIndex方法
- forEach方法
- indexOf方法
- join方法
- keys方法
- lastIndexOf方法
- map方法
- pop方法
- push方法
- reduce方法
- reduceRight方法
- reverse方法
- shift方法
- slice方法
- some方法
- sort方法
- splice方法
- toString方法
- unshift方法
- valueOf方法
- values方法
- ArrayBuffer对象
- byteLength属性
- ArrayBuffer.isView函数
- slice方法
- arguments对象
- 0...n 属性(参数)
- callee 属性(参数)
- length 属性 (arguments)
- Boolean对象
- constructor 属性(布尔值)
- prototype 属性(布尔值)
- toString 方法 (Boolean)
- valueOf 方法 (Boolean)
- DataView对象
- buffer属性 (DataView)
- byteLength属性(DataView)
- byteOffset属性(DataView)
- getInt8方法(DataView)
- getUint8方法(DataView)
- getInt16方法(DataView)
- getUint16方法(DataView)
- getInt32方法(DataView)
- getUint32方法(DataView)
- getFloat32方法(DataView)
- getFloat64方法(DataView)
- setInt8方法(DataView)
- setUint8方法(DataView)
- setInt16方法(DataView)
- setUint16方法(DataView)
- setInt32方法(DataView)
- setUint32方法(DataView)
- setFloat32方法(DataView)
- setFloat64方法(DataView)
- Date对象
- Debug对象
- Enumerator对象
- Error对象
- Float32Array对象
- Float64Array对象
- Function对象
- Global对象
- Int8Array对象
- Int16Array对象
- Int32Array对象
- Intl.Collator对象
- Intl.DateTimeFormat对象
- Intl.NumberFormat对象
- JSON对象
- Map对象
- Math对象
- Number对象
- Object对象
- Promise对象
- 代理对象
- Reflect对象
- RegExp对象
- 正则表达式对象
- Set对象
- String对象
- 符号对象
- Uint8Array对象
- Uint8ClampedArray对象
- Uint16Array对象
- Uint32Array对象
- VBArray对象
- WeakMap对象
- WeakSet对象
- WinRTError对象