If you directly add /n to multiple lines directly in the javascript code:
The code copy is as follows:
alert("first line/n second line");
But in java code, /n cannot do it, only //n can display multiple lines! ! !
The code copy is as follows:
String strTemp="Historical Answer Report: //n"+"You answered correctly"+RdData.getCcnt()+"Questions//n"+"You have"+RdData.getBcnt()+"No answers//n"+"You answered wrong"+RdData.getWcnt()+"Questions//n";
out.print("<script> alert('"+strTemp+"');window.location='index.jsp'</script>");
First, a String variable is declared (note that the line break is //n!!!), and then put it in alert. After the page is finished, the page will jump to the home page.
Here is the test result:
Here is the special character code in javascript:
The code copy is as follows:
Code Outputs
/' single quote
/" double quote
// backslash
/n new line
/r carriage return
/t tab
/b backspace
/f form feed