Programming

IE9에서 Javascript에서 VBScript로 아무것도 전달하지 않음

procodes 2020. 7. 10. 21:38
반응형

IE9에서 Javascript에서 VBScript로 아무것도 전달하지 않음


VBScript로 작성된 프레임 워크가 있습니다. 이 프레임 워크의 일부 함수 내에서 함수의 매개 변수는 Nothing in If 문에 대해 점검 된 후 일부 조치가 실행됩니다. 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>

IE <9에서 출력은 Nothing, Null, Nothing입니다.

IE9에서 : Nothing, Null, Null.

IE9에서 Javascript에서 VBScript로 Nothing을 전달하려면 어떻게해야합니까?

미안하지만 못 생겼다는 걸 알지만 갇혀 있습니다. 그리고 VBScript를 싫어합니다.

편집 : 프레임 워크 기능의 예가 있습니다. 응용 프로그램에서 널리 사용되므로 변경할 수 없습니다.

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

최신 정보

일을 종료했습니다. 더 나은 것을 찾았습니다.


불행히도, 아마도 여기에 갇혀있을 것입니다. JavaScript에는 "Nothing"에 해당하는 것이 없습니다. 자세한 내용은 이 기사 를 참조하십시오.

[편집] 그러나 다음과 같이 작동 할 수 있습니다. VBScript에서 "Nothing"을 리턴하는 "GetNothing"이라는 함수를 작성하십시오. JavaScript에서 "var jsNothing = GetNothing ()"을 사용하십시오. 이 기사 에서 나온다


이 질문은 흥미 롭습니다. 재미를 위해서만 대답하려고 노력했습니다.

(더 나은 일자리를 얻는 것을 축하합니다!)

지금은 IE에 액세스 할 수 없으므로 이것을 테스트 할 수 없지만 다음과 같은 함수를 작성하려고하면 어떻게됩니까?

<script type="text/vbscript">
  Function CallWithNulls(fn, arg1, arg2, arg3)
    If (isNull(arg1)) arg1 = Nothing
    If (isNull(arg2)) arg2 = Nothing
    If (isNull(arg3)) arg3 = Nothing
    fn(arg1, arg2, arg3)
  End Function
  Function IsNothing(arg1, arg2, arg3)
     return arg1 is Nothing
  End Function
</script>
<script type="text/javascript">
  alert(CallWithNulls(IsNothing, null, 1, 2));
</script>

물론 VB 스크립트가 이와 같은 함수를 호출 할 수 있는지 여부는 알 수 없으며 더 많거나 적은 인수를 처리해야합니다.


Use a value such as zero or even a negative number that would allow for you simply use falsy evaluations, then you don't have to worry about different browsers and their quirks in evaluating the NULL object.


As an example, something like this will work but if the browser is IE11 or later you will need the 'meta' tag.

<HTML>
<HEAD>
<meta http-equiv="x-ua-compatible" content="IE=10">
<TITLE>Pass Javscript to VBScript</TITLE>

<script>
    var val = "null";

    window.alert("Test: " +  val);
</script>

<script type="text/vbscript">

    PassNothing(val)


    Sub PassNothing(value)
        If LCase(value) = "null" Then
            MsgBox "Java passed 'null' so VBScript = 'Nothing'"
        Else
            Msgbox "Nothing received"
        End If
    End Sub

    </script>

</HEAD>
</HTML>

참고URL : https://stackoverflow.com/questions/7568471/pass-nothing-from-javascript-to-vbscript-in-ie9

반응형