如何在 JavaScript 警报框中提供新行?


若要在 JavaScript 警报框中添加新行,请使用 “

alert("Line One
Line Two");

实例

你可以尝试运行以下代码在 JavaScript 警报框中添加新行

实时演示

<html>
   <head>
      <script>
         <!--
            function Warn() {
               alert ("This is a warning message!
This is a new line.");                document.write ("This is a warning message!");             }          //-->       </script>    </head>    <body>       <p>Click the following button to see the result: </p>       <form>          <input type="button" value="Click Me" onclick="Warn();" />       </form>    </body> </html>

更新于: 08-Jan-2020

612 次浏览

开启你的 职业生涯

通过完成本课程来获得认证

开始学习
广告
© . All rights reserved.