How to mix Classic ASP and Server-Side Javascript
You have a ASP Classic site like this:
<% dim product : product = "apple" response.write product %> ...
And you need to create a new function to get the product name.
But, you don't want to do it in VBScript, because you prefer JavaScript.
All you need to do is to create an 'include' file, in pure javascript, like this:
includeJS.inc:
function getProduct(){ var product = "apple"; return product; }
And, add it to your existing ASP file:
< script runat="server" language="javascript" src="includeJS.inc" > < /script >
Finally, you can fix your existing code like this:
< % response.write getProduct % >
Yes, the VB code can call JS function directly.
Also, your JS code can also use already existing VBScript functions and variables.
You can also run with ScriptContol like so:
< % Response.Write URLDecode Function URLDecode(ByVal s) With CreateObject("ScriptControl") .Language = "JavaScript" URLDecode = .Eval("decodeURIComponent(""" & str & """.replace(/\+/g,"" ""))") End With End Function % >