函数里的document.write()为什么会清除掉当前网页内容?如果现在当前网页内容下顺序输出要怎么做?
如题。实验代码:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>confirm</title>
<script type="text/javascript">
document.write("hello");
function rec(){
var mymessage=confirm("你是女士吗?") ;
if(mymessage==true)
{
document.write("你是女士!");
}
else
{
document.write("你是男士!");
}
</script>
</head>
<body>
<h1>练习,这段话在点击按钮后会消失</h1>
<input name="button" type="button" onClick="rec()" value="点击我,弹出确认对话框" />
</body>
</html>