第三章 输入输出工具
2020-02-21 本文已影响0人
荼蘼toome
输入
语法:prompt(对话框 中显示的纯文本,默认的输入文本);//两个参数均为可选
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
prompt();//此时,加载时直接跳出一个输入框;简称:输入弹框
</script>
</head>
</html>
![](https://img.haomeiwen.com/i18618153/0d9f36f22118a428.png)
prompt("请输入姓名!");
![](https://img.haomeiwen.com/i18618153/bcece2fc563af3c7.png)
prompt("请输入姓名!","事实");
输出弹框,警告框
语法:alert("");//弹出带有一个确定按钮的警告框
输出工具
语法:document.write("");//文档中
向文档中写入html代码
document.write("<span style='color:red;'>hello world!</span>");
优点:可以有多段代码