Pass Nothing from Javascript to VBScript in IE9

mixel picture mixel · Sep 27, 2011 · Viewed 11.2k times · Source

I have a framework written in VBScript. Inside some function in this framework parameter of the function is checked for Nothing in If statement and then some actions executed. Code that uses framework written in Javascript. So I need to pass Nothing to function to perform some actions. In IE8 and earlier versions worked next approach:

<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>

In IE < 9 output will: Nothing, Null, Nothing.

In IE9: Nothing, Null, Null.

How can I pass Nothing from Javascript to VBScript in IE9?

Sorry, I know it's ugly, but I'm trapped. And hate VBScript.

edit: There is an example of framework function. I can not change it because it is widely used in application.

Function ExampleFunction(val)
    If (val Is Nothing) Then
        ExampleFunction = 1
    Else
        ExampleFunction = 0
    End If
End Function

Update

Quit job. Found a better one.

Answer

Pandelon picture Pandelon · Feb 16, 2012

Unfortunately, you are probably stuck here - JavaScript does not have a "Nothing" equivalent. See This Article for more information.

[Edit] However, the following may work. In your VBScript create a function called "GetNothing" that returns "Nothing". In your JavaScript use "var jsNothing = GetNothing()". Comes from this article