我冲这个:
The write() method is mostly used for testing: If it is used after an
HTML document is fully loaded, it will delete all existing HTML.
所以我决定测试一下,我写了这段代码:
I'm TEST which should be a deleted?
var drink = "Red bull";
var lyrics = "";
var cans = 99;
while(cans > 0)
{
lyrics += cans + " cans of " + drink + " on the wall
";
cans--;
}
document.write(lyrics);
正如你所看到的,我添加了
I'm TEST which should be a deleted?
之后,我在我的script标记之间调用了document.write,该标记应该删除包含此段的所有现有html?
但输出是下一个:
但段落仍然存在,不应该通过以下这句话删除:
If it is used after an HTML document is fully loaded, it will delete
all existing HTML.