SERVER-SIDE Java Scripting
In an ASP file, can Java Script code lines appear within a <% %> block? I can only find VB examples. Testing attemps to use Java Script there kill the application, resulting in a server error message.
If permitted, how can writing to a page be accomplished?
you can use <script type="text/jscript" runat="server">, but to use <%, you have to set the page languge to jscript. that can be done in the ASP config, or by using the <%@ language="jscript" %> directive first thing in a single file.
First, thank you for taking the time to respond.
Yes, I had already gone the route of <%@ language="jscript" %>, but with no success for at least some JS statements that worked under "<script> </script>".
Please see the post "document.write". Some JS statments do not kill the server, but I cannot tell whether they are even working because I cannot reply back to the current web page, and its not like I can put "breakpoints" in the code like good old C++.
Placing "<script> </script>" within the <% %> also seems to be a No-No.
A couple of example JS code lines, indicating acceptable JS within "<% %>" would be helpful.
TO: rnd me
Let me be more specific. Below is the ASP file I've been using for testing.
<title>Testing Document Write</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
var a = 0;
var b = 1;
x = b/a; // No error generated; thus, not being executed.
var z = F();
// All of these cause the server to return an error page.
//alert("z = " & z);
//response.write("z = " & z);
//document.write("<p style='color:#0000ff'>This text is styled with the style attribute!</p>");
"Response.write()" - mind your case.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)