We would like to know how to replace backslash character with double backslash.
<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
<!--from ww w.j a v a2 s. c o m-->
var str = "\r\n";
var replaced = str.replace('\r\n', '\\r\\n');
document.writeln(replaced);
</script>
</body>
</html>
The code above is rendered as follows: