<script type="text/javascript">
//我是单行注释,我也要隐藏起来!
</script>
</head>
<body>
<inpute type="button" value="请点击我" onclick="nice()">
document.write("系好安全带,准备启航");
function nice(){
var wether=comfirm("准备好了吗");
if(wether==true)
{document.write("让我们起航吧");}
else
{document.write("继续学习吧!");}
}
输出语句和函数要在script 中定义,要不就是外部文件引用。不能在其他位置
<body>
<form>
<input type="button" value="请点击我" onclick="nice()">
</form>
<script type="text/javascript">
document.write("系好安全带,准备启航");
function nice(){
var wether=confirm("准备好了吗");
if(wether==true)
{
document.write("让我们起航吧");
}else
{
document.write("继续学习吧!");
}
}
</script>
</body>