如何在 HTML 中制作多行警告框

How to Make an Alert Box in HTML With Multiple Lines

有谁知道如何在 HTML 中制作多行警告框?我正在寻找这样的输出:

Rules:
1. Blah Blah Blah
2. Blah Blah Blah
3. Blah Blah Blah
[Cancel]   [Ok]

这是 javascript 中的代码:

function rules() {
  agree = confirm("RULES: 1. Blah Blah Blah<br> 2. Blah Blah Blah<br> 3. Blah Blah Blah<br> Press OK to agree and Cancel to Dissagree")
  if (agree == true) {
    alert("Thank you for agreeing to the rules!")
  } else {
    alert("You can not move on unless you agree to the rules.")
  }
}
<button onclick="rules()">Agree to the Rules</button>

我试过使用 <br>,但它们似乎没有在警告框中格式化。我得到的输出是这样的:

有谁知道如何将另一行添加到警告框中?

插入 \n 会创建一个新行

function rules() {
  agree = confirm("RULES: 1. Bl\nah Blah Blah 2. Bla\nh Blah Blah 3. Bla\nh Blah Blah Press OK to agree and Cancel to Dissagree")
  if (agree == true) {
    alert("Thank you for agreeing to the rules!")
  } else {
    alert("You can not move on unless you agree to the rules.")
  }
}
<button onclick="rules()">Agree to the Rules</button>

您将使用 '\n' 创建线条。

例如,您的规则字符串为:

'Rules:\n1. Blah Blah Blah\n2. Blah Blah Blah\n3. Blah Blah Blah'

警报("This is first Line \nThis is second line \nThis is third Line");