Sl********@bls.gov 如果您想要与客户共享一组功能,并且 服务器放置功能在VBS文件中。以此为例Test.vbs: - 函数DoSomething(a,b) DoSomething = a + b 结束函数 请注意,因为这是一个vbs文件,所以它不包含< %%> 现在这里是一个消耗的示例页面服务器端和 客户端的功能: - < script src =" test.vbs" RUNAT = QUOT;服务器" language =" vbscript">< / script> < html> < script src =" test.vbs" type =" text / vbscript">< / script> < script type =" text / vbscript"> 函数Body_Onload() divLocal.innerHTML =" 3 + 4 =" &安培; DoSomething(3,4) 结束功能 < / script> < body onload =" Body_Onload()"> ; 1 + 2 =<%= DoSomething(1,2)%> < div id =" divLocal" /> < / body> < / html> Anthony。 Hi All,i have this.asp page:<script type="text/vbscript">Function myFunc(val1ok, val2ok)'' do something okmyFunc = " return something ok"End Function</script><html><body><%val1ok = something1val2ok = something2thenewVal = myFunc((val1ok), (val2ok))%></body></html>i want to call and use the returned value of Function myFunc(val1ok,val2ok) ,without omitting the html script tags and replacing them in <% %>,(My Question is:)How do i call a function defined in html script tags from asp page? 解决方案You can''t call client-side code from server-side code. Nor vice-versa.Full stop.--Mike BrindYou don''t. The ASP code runs on the server, producing HTML as output.When the ASP code finishes, the resulting HTML is sent to the client.The client''s browser parses it, finding the Javascript code (amongother things). Since the server-side ASP function has finished and is*not* sent to the client, the client-side Javascript cannot call it.It doesn''t exist any more by the time the Javascript code runs.--Tim SlatteryMS MVP(DTS) Sl********@bls.govIf you have a set of functions you want to share with the client and theserver place the functions in a VBS file. Take this example Test.vbs:-Function DoSomething(a, b)DoSomething = a + bEnd FunctionNote that since this is a vbs file it does not contain <%%>Now here is an example page that consumes the function both server side andclient side:-<script src="test.vbs" runat="server" language="vbscript"></script><html><script src="test.vbs" type="text/vbscript"></script><script type="text/vbscript">Function Body_Onload()divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)End Function</script><body onload="Body_Onload()">1 + 2 = <%=DoSomething(1,2)%><div id="divLocal" /></body></html>Anthony. 这篇关于如何从asp页面调用html脚本标签中定义的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!