Задать вопрос

Используют ли document.write и почему бы нет?

<!DOCTYPE html>
<html>
<body>

<h2>My First Web Page</h2>
<p>My first paragraph.</p>

<p>Never call document.write after the document has finished loading.
It will overwrite the whole document.</p>

<script>
document.write(5 + 6);
</script>

</body>
</html>


https://www.w3schools.com/js/tryit.asp?filename=tr...

Может, я олень, но я считаю, что невнятно та объяснено про
It will overwrite the whole document.


сами видете, оно не overwrite
  • Вопрос задан
  • 123 просмотра
Подписаться 1 Простой 2 комментария
Решение пользователя bkosun К ответам на вопрос (3)
@bkosun
Метод document.write – один из наиболее древних методов добавления текста к документу.

У него есть существенные ограничения, поэтому он используется редко, но по своей сути он совершенно уникален и иногда, хоть и редко, может быть полезен.


https://learn.javascript.ru/document-write

<!DOCTYPE html>
<html>
<body>

<h2>My First Web Page</h2>
<p>My first paragraph.</p>

<p>Never call document.write after the document has finished loading.
It will overwrite the whole document.</p>

<script>
	document.addEventListener("DOMContentLoaded", function(){
		document.write(5 + 6);
	});
</script>


</body>
</html>


https://developer.mozilla.org/ru/docs/Web/Events/D...
Ответ написан
Комментировать