為什么confirm點(diǎn)擊完確定,按鈕消失了?
<script?type="text/javascript">
??function?rec(){
????var?mymessage=confirm("你是女士?")?????????;
????if(mymessage==true)
????{
???? document.write("你是女士!");
????}
????else
????{
????????document.write("你是男士!");
????}
??}???
??</script>
??
??<body>
????<input?name="button"?type="button"?onClick="rec()"?value="點(diǎn)擊我,彈出確認(rèn)對(duì)話框"?/>
</body>
2015-12-03
我自己搜到了。如下:
您只能在 HTML 輸出中使用 document.write。如果您在文檔加載后使用該方法,會(huì)覆蓋整個(gè)文檔。
所謂的HTML文檔加載,其實(shí)HTML文檔是自上而下的加載HTML表示的內(nèi)容,當(dāng)整個(gè)頁(yè)面內(nèi)容都加載完畢之后,再調(diào)用document.write()這方法會(huì)將顯示的頁(yè)面內(nèi)容都會(huì)清楚。
參考:
http://www.it165.net/design/html/201307/2165.html
2015-12-03
document.write("你是女士!");把整個(gè)網(wǎng)頁(yè)的內(nèi)容都修改了啊,
2015-12-01
confirm就是彈出一個(gè)確認(rèn)框而已,讓你做出選擇,選擇完了就消失。