简体   繁体   中英

Escape character in javascript

I have some server information in ASP that I need to pass through AJAX. However, the server name has a back slash.

var concode = "<%response.write(concode)%>";

But when stepping through the code the server name does not have the back slash.

How do I fix it so that the back slash stays in the server name?

The escape character is the backslash: JavaScript Special Characters

If this is classic ASP:

var concode = "<%=Replace(concode, "\", "\\")%>";

If it's VB.NET:

var concode = "<%=concode.Replace("\", "\\")%>";

Note: Depending on exactly how you've coded your page, those nested quotes may give the ASP parser fits.

要么转义反斜杠\\\\ == \\ ,要么使用encodeURI(servername)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM