mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
fix CreateObject
This commit is contained in:
parent
a62837ed25
commit
90d45137aa
23
app.js
23
app.js
|
@ -69,8 +69,27 @@ var console = {
|
|||
};
|
||||
|
||||
if (typeof(CreateObject) !== "function") {
|
||||
var CreateObject = function(className) {
|
||||
return new ActiveXObject(className);
|
||||
var CreateObject = function(progId, serverName) {
|
||||
var progIds = [];
|
||||
var _CreateObject = function(p, s) {
|
||||
if (typeof(WScript) !== "undefined") {
|
||||
return WScript.CreateObject(p, s);
|
||||
} else {
|
||||
return new ActiveXObject(p, s);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof(progId) == "object") {
|
||||
progIds = progId;
|
||||
} else {
|
||||
progIds.push(progId);
|
||||
}
|
||||
|
||||
for (var i = 0; i < progIds.length; i++) {
|
||||
try {
|
||||
return _CreateObject(progIds[i], serverName);
|
||||
} catch (e) {};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
23
lib/std.js
23
lib/std.js
|
@ -76,18 +76,25 @@ exports.require = global.require;
|
|||
// Emulate Server.CreateObject
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.CreateObject = function(objectName) {
|
||||
var objectNames = [];
|
||||
exports.CreateObject = function(progId, serverName) {
|
||||
var progIds = [];
|
||||
var _CreateObject = function(p, s) {
|
||||
if (typeof(WScript) !== "undefined") {
|
||||
return WScript.CreateObject(p, s);
|
||||
} else {
|
||||
return new ActiveXObject(p, s);
|
||||
}
|
||||
};
|
||||
|
||||
if(typeof(objectName) == "object") {
|
||||
objectNames = objectName;
|
||||
if (typeof(progId) == "object") {
|
||||
progIds = progId;
|
||||
} else {
|
||||
objectNames.push(objectName);
|
||||
progIds.push(progId);
|
||||
}
|
||||
|
||||
for (var i = 0; i < objectNames.length; i++) {
|
||||
try {
|
||||
return new ActiveXObject(objectNames[i]);
|
||||
for (var i = 0; i < progIds.length; i++) {
|
||||
try {
|
||||
return _CreateObject(progIds[i], serverName);
|
||||
} catch(e) {};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user