www.webdeveloper.com
Results 1 to 5 of 5

Thread: SERVER-SIDE Java Scripting

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Location
    Roanoke, VA
    Posts
    10

    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?

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    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.

  3. #3
    Join Date
    Feb 2013
    Location
    Roanoke, VA
    Posts
    10
    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.

    Thanks
    ROK

  4. #4
    Join Date
    Feb 2013
    Location
    Roanoke, VA
    Posts
    10
    TO: rnd me

    Let me be more specific. Below is the ASP file I've been using for testing.

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <title>Testing Document Write</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
    function DocumentWrite(sText)
    {
    document.write(sText);
    }
    </script>
    </head>

    <body>
    <%
    function F()
    {
    var a = 0;
    var b = 1;
    var x;
    x = b/a; // No error generated; thus, not being executed.
    return x;
    }

    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>");
    %>
    </body>
    </html>

  5. #5
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    "Response.write()" - mind your case.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles