[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對象