...

View Full Version : slashes



ShMiL
10-14-2005, 08:03 PM
how do I add slash "\" and backslash "/" to a string?

Thanks

Brandoe85
10-14-2005, 08:23 PM
The backslash is the escape character, so you'll have to escape it, but the forward slash you should have no problems with:


var str = "this is a backslash \\, this is a forward slash /";
alert(str);

Mr J
10-14-2005, 08:25 PM
You can add a forward slash as normal but a back slash is escaped with another backslash


<script type="text/javascript">
<!--
str1="hello/world"
alert(str1)

str2="hello\\world"
alert(str2)
-->
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum