我尝试从这个javascript调用vb函数,但我不能称之为vb。
我需要在这个javascript代码中调用vb函数..我已经使用response.write
将javascript嵌入到vb代码中
有人可以帮助我吗?
这是我的代码:
Response.Write("<" & "script>")
Response.Write("var r =confirm(""File Already Exist! Are you want to continue?"");")
Response.Write("if (r==true)")
Response.Write("{")
Response.Write("function callVB()")
Response.Write("{")
我想在vb函数中调用此函数messagebox2()
:
Response.Write("MessageBox2();")
Response.Write("}")
Response.Write("}")
Response.Write("else")
Response.Write("{")
Response.Write("function callVB1()")
Response.Write("{")
Response.Write("'" & strFilename & "';")
Response.Write("}")
Response.Write("}")
Response.Write("<" & "/script>")
当我点击“确定”按钮时,它不会调用函数messagebox2()
答案 0 :(得分:0)
不完全确定您希望实现的目标,但如果您尝试从客户端javascript调用客户端vbscript,那么这里有一个示例可以指导您:
<%
Response.Write ("<" & "script type=""text/VBScript"">"& vbcrlf)
Response.Write ("<!--"& vbcrlf)
Response.Write (" sub VBFunc()"& vbcrlf)
Response.Write (" Msgbox( ""Hello From VBScript"")"& vbcrlf)
Response.Write (" end sub"& vbcrlf)
Response.Write ("//-->"& vbcrlf)
Response.Write ("<" & "/script>"& vbcrlf)
Response.Write ("<" & "script type=""text/javascript"">"& vbcrlf)
Response.Write ("<!--"& vbcrlf)
Response.Write (" if (confirm(""File Already Exists! Do you want to continue?""))"& vbcrlf)
Response.Write (" {"& vbcrlf)
Response.Write (" VBFunc();"& vbcrlf)
Response.Write (" }else{"& vbcrlf)
Response.Write (" alert('you clicked Cancel');"& vbcrlf)
Response.Write (" }"& vbcrlf)
Response.Write (" //-->"& vbcrlf)
Response.Write ("<" & "/script>"& vbcrlf)
%>