level 3
jessylake
楼主
Sub tt1()
Set objDom = CreateObject("htmlfile")
Set objWin = objDom.parentWindow
strJS = "<script> function judge(){var a=[1,2,3];if(a.constructor==Array){return ""yes""}return ""no""} </script>"
objDom.write strJS
Msgbox CallByName(objWin, "judge", VbMethod)
End Sub
Sub tt2()
Set objDom = CreateObject("htmlfile")
Set objWin = objDom.parentWindow
strJS = "<script> function judge(){var a=[1,2,3];if (Array.isArray(a)){return ""yes""}return ""no""} </script>"
objDom.write strJS
Msgbox CallByName(objWin, "judge", VbMethod)
End Sub
Sub tt3()
Set objDom = CreateObject("htmlfile")
Set objWin = objDom.parentWindow
ar = Array("a", "b", "c")
strJS = "<script> function judge(a){if(a.constructor==Array){return a}return Array.from(a)} </script>"
objDom.write strJS
Msgbox CallByName(objWin, "judge", VbMethod, ar)
End Sub
只有tt1没有报错,后面两个都报错了,什么原因?
2018年08月08日 14点08分
1
Set objDom = CreateObject("htmlfile")
Set objWin = objDom.parentWindow
strJS = "<script> function judge(){var a=[1,2,3];if(a.constructor==Array){return ""yes""}return ""no""} </script>"
objDom.write strJS
Msgbox CallByName(objWin, "judge", VbMethod)
End Sub
Sub tt2()
Set objDom = CreateObject("htmlfile")
Set objWin = objDom.parentWindow
strJS = "<script> function judge(){var a=[1,2,3];if (Array.isArray(a)){return ""yes""}return ""no""} </script>"
objDom.write strJS
Msgbox CallByName(objWin, "judge", VbMethod)
End Sub
Sub tt3()
Set objDom = CreateObject("htmlfile")
Set objWin = objDom.parentWindow
ar = Array("a", "b", "c")
strJS = "<script> function judge(a){if(a.constructor==Array){return a}return Array.from(a)} </script>"
objDom.write strJS
Msgbox CallByName(objWin, "judge", VbMethod, ar)
End Sub
只有tt1没有报错,后面两个都报错了,什么原因?