ASP does not recognize leading spaces when calculating line length

This multi-line string when created by the browser has the expected length:

<script type="text/javascript">
var s = "\
    a";
document.write(s.length);
</script>

Outputs 5

But when executed as scritp on the server side of the ASP, it returns 1:

<%@ Language=JavaScript %>
<%
var s = "\
    a";
Response.Write(s.length);
%>

What happens is that the ASP version of Javascript feeds on leading spaces when used in multi-line strings.

How to make the ASP version behave the same as the browser version?

+3
source share
2 answers

If you include \at the beginning of your line, asp recognizes spaces.

<%@ Language=JavaScript %>
<%
var s = "\
\    a";
Response.Write(s.length);
%>

I was unable to use the character \to create multi-line strings. Neatly, but I could not find the documentation for this. Think it just eludes a line break? Do you have a link to the link?

, :

<pre>
<%
var s = "\
    unescaped";
Response.Write(s);
Response.Write("\n");
s = "\
\    escaped";
Response.Write(s);
%>
</pre>

:

unescaped
    escaped
+1

html, , html . ' ', html.

0

All Articles