在IE9中从Javascript传递给VBScript

mix*_*xel 123 javascript vbscript internet-explorer-9

我有一个用VBScript编写的框架.在这个框架内部的一些函数中,函数的参数在If语句中检查Nothing,然后执行一些动作.使用Javascript编写的框架的代码.所以我需要传递Nothing来执行某些操作.在IE8和早期版本中工作的下一个方法:

<script type="text/vbscript">
    Function Test(val)
        If (IsNull(val)) Then
            Test = "Null"
        ElseIf (IsObject(val)) Then
            If (val Is Nothing) Then
                Test = "Nothing"
            End If
        End If
    End Function

    Dim jsNothing
    Set jsNothing = Nothing
    msgBox(Test(jsNothing))
    msgBox(Test(Null))
</script>


<script type="text/javascript">
    alert(Test(jsNothing));
</script>
Run Code Online (Sandbox Code Playgroud)

在IE <9中输出将:Nothing,Null,Nothing.

在IE9中:没有,Null,Null.

如何在IE9中将Nothing从Javascript传递给VBScript?

对不起,我知道这很丑,但我被困了.并讨厌VBScript.

编辑: 有一个框架功能的例子.我无法改变它,因为它在应用中被广泛使用.

Function ExampleFunction(val)
    If (val Is Nothing) Then
        ExampleFunction = 1
    Else
        ExampleFunction = 0
    End If
End Function
Run Code Online (Sandbox Code Playgroud)

更新

退出工作.找到一个更好的.

Pan*_*lon 17

不幸的是,你可能被困在这里 - JavaScript没有"Nothing"等价物.有关更多信息,请参阅此文章.

[编辑]但是,以下可能有效.在你的VBScript中创建一个名为"GetNothing"的函数,它返回"Nothing".在您的JavaScript中使用"var jsNothing = GetNothing()".来自这篇文章


Tim*_*ake 0

使用零甚至负数等值。这将允许您简单地使用虚假评估,然后您不必担心不同的浏览器及其在评估对象时的怪癖NULL