我有一个用VBScript编写的框架。在这个框架的某些函数内部,会检查函数的参数是否为Nothing,如果是,则执行一些操作。
使用该框架的代码是用JavaScript编写的。因此,我需要将Nothing传递给函数以执行一些操作。在Internet Explorer 8和早期版本中,以下方法有效:
在Internet Explorer 9之前,输出将为:Nothing,Null,Nothing。
在Internet Explorer 9中:Nothing,Null,Null。
如何在Internet Explorer 9中从JavaScript传递Nothing到VBScript?
这里有一个框架函数的示例。我无法更改它,因为它被广泛用于应用程序。
使用该框架的代码是用JavaScript编写的。因此,我需要将Nothing传递给函数以执行一些操作。在Internet Explorer 8和早期版本中,以下方法有效:
<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>
在Internet Explorer 9之前,输出将为:Nothing,Null,Nothing。
在Internet Explorer 9中:Nothing,Null,Null。
如何在Internet Explorer 9中从JavaScript传递Nothing到VBScript?
这里有一个框架函数的示例。我无法更改它,因为它被广泛用于应用程序。
Function ExampleFunction(val)
If (val Is Nothing) Then
ExampleFunction = 1
Else
ExampleFunction = 0
End If
End Function
IsObject(val) And val Is Nothing
仍会导致错误。您需要将其拆分为嵌套的 If 语句。 - Cheran Shunmugavel