為什么confirm點擊完確定,按鈕消失了?
<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="點擊我,彈出確認對話框"?/> </body>
2015-12-03
我自己搜到了。如下:
您只能在 HTML 輸出中使用 document.write。如果您在文檔加載后使用該方法,會覆蓋整個文檔。
所謂的HTML文檔加載,其實HTML文檔是自上而下的加載HTML表示的內(nèi)容,當整個頁面內(nèi)容都加載完畢之后,再調(diào)用document.write()這方法會將顯示的頁面內(nèi)容都會清楚。
參考:
http://www.it165.net/design/html/201307/2165.html
2015-12-03
document.write("你是女士!");把整個網(wǎng)頁的內(nèi)容都修改了啊,
2015-12-01
confirm就是彈出一個確認框而已,讓你做出選擇,選擇完了就消失。