JavaScript string newline character?

后端 未结 15 1926
终归单人心
终归单人心 2020-11-22 08:06

Is \\n the universal newline character sequence in Javascript for all platforms? If not, how do I determine the character for the current environment?

I

相关标签:
15条回答
  • 2020-11-22 08:41

    you can use <br/> and the document.write/, document.writeln one.

    0 讨论(0)
  • 2020-11-22 08:44

    Email link function i use "%0D%0A"

    function sendMail() {   
    var bodydata="Before "+ "%0D%0A";
        bodydata+="After"
    
    var MailMSG = "mailto:aaa@sss.com" 
             + "?cc=07@sss.com" 
             + "&subject=subject" 
             + "&body=" + bodydata; 
    window.location.href = MailMSG; 
    } 
    

    [HTML]

    <a href="#" onClick="sendMail()">Contact Us</a>
    
    0 讨论(0)
  • 2020-11-22 08:45

    Yes, it is universal.

    Although '\n' is the universal newline characters, you have to keep in mind that, depending on your input, new line characters might be preceded by carriage return characters ('\r').

    0 讨论(0)
提交回复
热议问题