點完確認之后,為什么之前的文本就消失換掉了呢?什么邏輯,再多些幾行p標(biāo)簽的內(nèi)容也是會被換掉,怎么理解
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我們互動下</title>
<script type="text/javascript">
? ?function jump() ?
? ? {
? ? var mymessage=confirm("關(guān)注JS高級篇");
? ? if(mymessage==true)
? ? {
? ? ? ? document.write("恭喜您進入年薪百萬的節(jié)奏!");
? ? }
? ? else
? ? {
? ? ? ? document.write("o(︶︿︶)o 唉!不管你是男屌絲還是女屌絲,不學(xué)習(xí)你始終都會是個屌絲……!");
? ? }
? } ? ? ??
</script>
</head>
<body>
<p id="con">js進階篇</p>
<form>
? ? ? ?<input type="button" onclick="jump()" value="點擊進入" />?
? ? </form>
</body>
</html>
2017-02-25
因為事件是在文檔內(nèi)容完全加載完畢再去執(zhí)行事件處理函數(shù),當(dāng)然文檔流已經(jīng)關(guān)閉了,這個時候執(zhí)行doucment.writ()函數(shù)會自動調(diào)用document.open()函數(shù)創(chuàng)建一個新的文檔流,并寫入新的內(nèi)容,再通過瀏覽器展現(xiàn),這樣就會覆蓋原來的內(nèi)容。
2017-02-17
應(yīng)該是調(diào)用JavaScript函數(shù),會增加個新頁面輸出document.write();