Can't add new lines in JavaScript alert Box?

前端 未结 2 1404
自闭症患者
自闭症患者 2021-01-24 10:45

I\'m generating a string in PHP and then eventually passing this string into a JavaScript alert box, my problem is I actually can\'t add line breaks in my alert box.

My c

2条回答
  •  抹茶落季
    2021-01-24 11:25

    This happens because PHP interprets the \n before JavaScript has the chance to, resulting in a real line break inside the Javascript code. Try

    \\n
    

提交回复
热议问题