0

我正在为 IE 开发一个通过 javascript 调用的 ActiveX 控件。ActiveX 控件是在 Visual Basic 中开发的,它有一个字符串数组。我将如何在 javascript 中使用这个字符串数组。

例如:-

var a = new Array()
a = objActiveX.GetArray(); // call to active x returns array of string, how will I loop through this in javascript. 

上面的行不起作用。我想遍历javascript中的每个字符串。

建议。

4

2 回答 2

1

此函数将多维 VB 安全数组转换为多维 javascript 数组。

试试看,如果你能打破它,请告诉我。

于 2012-07-03T02:06:52.180 回答
1

Usually, arrays returned from COM/OLE/ActiveX components are SAFEARRAYs. There's a special object in JScript called VBArray that adapts between the two.

See http://blogs.msdn.com/b/david.wang/archive/2006/07/04/howto-convert-between-jscript-array-and-vb-safe-array.aspx for a good example of going back and forth between JavaScript arrays and SAFEARRAYs.

More detailed info on VBArray here: http://msdn.microsoft.com/en-us/library/3s0fw3t2(VS.80).aspx

Note that this is part of JScript -- I'm not 100% sure that IEs default scripting runtime is JScript, but I think so.

于 2010-12-07T12:52:20.817 回答