Begin:
You can have JavaScript and VBScript implement music from the same table. Look at the following script:
<textarea id="runcode70728"><% @LANGUAGE = "javascript"%> <script language= "javascript" runat= "Server" > Function jsgreeting () { Return "Greetings from a JavaScript Function"; } </SCRIPT> <script language= "VBScript" runat= "Server" > Function vbgreeting () vbgreeting= "Greetings F" Rom a VBScript function "End Function function Todollars (x) todollars=formatcurrency (x) End Function </script > <% var a = 2; var B = 2; var c = Add (a,b) c + = "(two numbers are added by JavaScript," C + = "and then into formatted by VBScript.)" function Add (x,y) {result = x + y; result = Todollars (result); return result; } Response.Write ("<ptml>\r") Response.Write (jsgreeting () + "\ R") Response.Write (vbgreeting () + "\ r") Response . Write (c + "\ r") Response.Write ("</ptml>\r")%></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
RUNAT:
Let's break it down from beginning to end. The following list is a simple and independent javascript:
If it weren't for the humble runat= "Server," it would look like a simple javascript you might see on the client.
The Runat property tells the server to execute it on the server side, so the client will never see it. You can also set the property to runat= "client" so that you can skip the server side and execute it directly on the client.
By the way, it cannot be placed inside the ASP tag.
Look at the following VBScript:
Function vbgreeting ()
Vbgreeting= "Greetings from a VBScript Function"
End Function
This VBScript implements the same functionality as JavaScript. There's nothing special about it.
However, the following VBScript has something special.
Function Todollars (x)
Todollars=formatcurrency (x)
End Function
Reference:
The function above returns a parameter from JavaScript. Then he would return the most appropriate value to JavaScript. Let's take a look at how function todollars (x) is referenced.
function Add (x,y)
{
result = x + y;
result = Todollars (result);
return result;
}
function Add (x,y) is a JavaScript function. From the middle of the function you can see
result = Todollars (result);
The line above is actually a call from VBScript to JavaScript.
Warning:
As a warning. When you create a script with the Runat attribute, you are actually arranging the order in which it is executed. I'm not going to go into that, because the order of execution depends on the situation.
Here's what I'll go into: Use the Runat property only on functions (and the global variables that are called within the function). Don't put the top layer of code in it because you can't guarantee that the top-level code will change the order of execution with this technique.
Original and example address of this section: http://aspjavascript.com/lesson04.asp
Original Author: James Clark translation: Huahua reprint Please specify