I red this:
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.
So I decided to test this, I wrote this code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p>I'm TEST which should be a deleted?</p>
<script>
var drink = "Red bull";
var lyrics = "";
var cans = 99;
while(cans > 0)
{
lyrics += cans + " cans of " + drink + " on the wall <br>";
cans--;
}
document.write(lyrics);
</script>
</body>
</html>
As you can see I added <p>I'm TEST which should be a deleted?</p>
after that I invoked document.write between my script tag which should delete all existing html including this paragraph?
But output is next:
But paragraph is still there, shouldn't it be removed by following this sentence:
If it is used after an HTML document is fully loaded, it will delete all existing HTML.
