1

I am new to html. My below code when I click on "Lol Me" button the webpage is turning blank? instead of "LOL". What is wrong in the below code.

<html>
<body>
Hi there<br>

<script>
var x = "John said, \"Boy this is good\"";
var y = true;
function write(){
  document.write('LOL');
}

function funcy(){
  alert('Trozan virus');
}

</script>

<input type="button" value="press me" onclick="funcy()">
<input type="button" value="Lol me" onclick="write()">
</body>
</html>

Regards, Bhanu

  • No-one uses document.write in the real world. Don't worry about it and find another example to follow. – geoidesic Feb 07 '19 at 19:47
  • If [`document.write`](https://developer.mozilla.org/en-US/docs/Web/API/Document/write) used after page load, the HTML content of the page will be **overwritten** by new content. – FZs Feb 07 '19 at 19:53
  • geoidesic lol.. is it ? thanks for clearing that up. if you have write it as a answer, I would have marked it as a accepted. – Sandhya Thotakura Feb 07 '19 at 20:28

0 Answers0