& lt; Script language="javascript" type="text/javascript" runat="server" & gt;
Then in the asp file directly in js function called Add (s) is not effective, what is this?
& lt; %
Data="https://bbs.csdn.net/topics/abc"
A=Demo (Data)
The function Demo (Data)
Sum=Add (Data)
End the function
%>
CodePudding user response:
& lt; Script runat="server" & gt; Now is executed on the server side, you Add function is the client side& lt; Script runat="server" & gt; & lt;/script> Can only be placed in the methods and properties, etc., and not directly add statements and expressions,
And you use & lt; % % & gt; Mark, the use of the symbol has certain limitations, which cannot declare functions or subroutines, can only be placed statement
CodePudding user response:
So, I want to use what format can call the Add function in ASP, I directly use the Add (Data) will become bad, is to use the method of problem, or the function itself?& lt; %
The function Demo (Data)
Sum=Add (Data)//call the Add function of js, direct assignment that is feasible?
End the function
%>
CodePudding user response:
Asp code will be executed by the server, implementation results and other content is sent to the client together, again by the client to perform the HTML/CSS/js,So can't execute the client code in the server code,
If you realize the Add operation on the client, and the logic of asp to calculate, need to be submitted to the server, access parameters, calculation again returned to the client,
================================
In fact, I was passing by, see I haven't the account what for a decade,,,
CodePudding user response:
The first thing you want to make sure your JS is to run on the server side, or run on the client,Look at your code using VBSCRIPT, that your JS should be running the client,
Suppose your JS has a function in the Demo (Data),
In ASP set, you written: response. Write "& lt; script> The Demo (Data); & lt;/script>"
So that the client will do the operation,
CodePudding user response:
Js code and asp together (that is, the js code should be placed in the asp source code only), guarantee can realize :
& lt; Script language="javascript" type="text/javascript" runat="server" & gt;
The function to the Add (Data) {
.
}
& lt;/SCRIPT>
& lt; %
Data="https://bbs.csdn.net/topics/abc"
A=Demo (Data)
The function Demo (Data)
Sum=Add (Data)
End the function
%>
CodePudding user response:
You can call? I only know that js can call the inside of the asp method, such as: winFormCodePudding user response:
I only know that js?????? blademasterCodePudding user response:
Don't be this: runat="server"Response. Write "& lt; script> The Demo (Data); & lt;/script>"
The return value:) how to get won't
CodePudding user response:
Now, don't use ajax?CodePudding user response:
Is nothing wrong with that of the building Lord problem is to open the iis error echo, and the likely blind a few turn off writing global vbscript error suppression on error goto 0, it is good for you to see the specific error to analyze what is write wrong, always thought that so long as written well, asp is best than other languages, especially can run vb and js, but too many developers had half a bucket of water, also blame is too easy to learn, an informal introduction to web site and end up dead,,,In tell everyone a cow a force:
& lt; % % & gt; When the default execution in vbscript (IIS) can modify the default into other languages, & lt; Script language="javascript" runat="server" & gt; The js script runs higher priority than vbscript, it means that js code will first, completing execution of the then perform vbscript, bad?? This feature is very useful,
CodePudding user response:
Seem to do,Js get browser width=document. Body. ClientWidth; (not display width), want to return it to the ASP as a variable's value I can't do!