Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2003
    Location
    East Grinstead ,UK
    Posts
    19

    Unanswered: javascript syntax in ASP

    CAn some one help me out with this javascript (ahh!!)
    This is the line :

    Response.write('<A HREF="javascript:newGuidanceWindow(qmsadditionalin fo.asp?doc_id='+ escape(d1.data[i].doc_id)+')">');

    This is the function that i'm calling:

    function newGuidanceWindow(newWin,name, features) {

    newWin =window.open( newWin, 'my_window','toolbar=no,titlebar=no,location=no,di rectories=no,status=no,menubar=no,scrollbars=no,re sizable=yes,copyhistory=no,width=300,height=300');
    }
    </script>

    I know that the function works outside the <% %> syntax of ASP. Can you tell me what I'm doing wrong?

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    You should use " not ' as a string delimter, you also need to double any which you actually want in the string.

    i.e.

    Code:
    response.write("hello")
    writes
    hello
    Code:
    response.write("hello ""this is a test""....")
    writes
    hello "this is a test"....
    easiest way if you have trouble is to just break out of the ASP

    Code:
    blah blah
    %>
    <A HREF="java script:newGuidanceWindow(qmsadditionalinfo.asp?doc_id=<%=escape(d1.data[i].doc_id)%>)">
    <%
    some more code
    or the other way (like your doing now);
    Code:
    response.write "<A HREF=""java script:newGuidanceWindow(qmsadditionalinfo.asp?doc_id=" & escape(d1.data[i].doc_id) & ")"">"
    hope this makes sense...
    Last edited by rhs98; 04-25-03 at 18:08.

  3. #3
    Join Date
    Apr 2003
    Location
    NY
    Posts
    3

    Re: javascript syntax in ASP

    If you are using javascript on the server then either double or single quotes as a delimiter is fine. You esape them using a backslash and not by doubling them:


    Response.Write("hello \"this is a test\"....")

    What is the error you are recieving?


    -John lemp

  4. #4
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    erm doubling works too...

  5. #5
    Join Date
    Apr 2003
    Location
    NY
    Posts
    3
    Then why does this:

    <%@ Language=Javascript %>
    <%
    Response.write("hello ""this is a test""....") ;
    %>

    Result in this:

    Error Type:
    Microsoft JScript compilation (0x800A03EE)
    Expected ')'
    /test.asp, line 3, column 23
    Response.write("hello ""this is a test""....") ;
    ----------------------^

  6. #6
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Becuase I was talking about VBScript....

Posting Permissions

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