苏沂南
2019-02-27 10:26
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<!--引入外部文件的方式-->
<script type="text/javascript" src="script.js">
//多行注释
/*我是多行注释!
我需要隐藏,
否则会报错哦*/
//在页面中显示文字
//document.write("页面文字");
//页面中弹出提示框
//alert("弹出框文字");
//单行注释
//我是单行注释,我也要隐藏起来!
</script>
</head>
<body>
<input type="button" onclick="alertf()" value="弹框">
</body>
</html>
//编写JS代码
document.write("系好安全带,准备起航--目标JS");
function alertf(){
alert("准备好了,起航吧");
}
function alertf(){
alert("准备好了,起航吧");
}
<script type="text/javascript">
document.write("系好安全带,准备起航--目标JS");
function alertf(){
alert("准备好了,起航吧");
}
</script>
这样试试
看一下自己用的是什么浏览器吧 火狐的是可以完美实现的 有些浏览器不太行
你的弹出写在函数里,函数又没运行,怎么可能会有弹出框
你 document.write("系好安全带,准备起航--目标JS"); 这句后面的分号用的是中文分号
JavaScript进阶篇
468602 学习 · 21893 问题
相似问题