2011-06-30 55 views
-3

我嘗試從此JavaScript調用vb函數,但我無法調用該vb。
我需要調用這個javascript代碼裏面動功能..我已經內嵌到的JavaScript代碼VB使用response.write如何使用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("{") 

我要調用此函數messagebox2()這是在VB功能:

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

有人可以給我解決方案的建議 – faizalSalleh

+0

嗨user714435 - 你的問題不清楚。這是在瀏覽器中?在IE中?什麼是「響應」類/範圍? –

+0

我開發的網站..我測試使用IE ..我需要調用JavaScript中的MessageBox2函數。 -Response.Write(「MessageBox2();」) - – faizalSalleh

回答

0

不完全確定你希望完成什麼,但是如果你正試圖從客戶端JavaScript調用客戶端的vbscript,那麼這裏是一個e xample可能會引導你:

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

%> 
+0

感謝您的幫助......我幾乎解決這個問題..謝謝 – faizalSalleh