0

I have used document.write('Test') in my HTML page.

Everything is working as intended but I am just curious to know why this output 'Test' which appears in the browser does not appear in "View Page Source".

So the output of this document.write() is stored only in the browser memory?

Biffen
  • 5,354
  • 5
  • 27
  • 32
Rainmaker
  • 127
  • 5

2 Answers2

3

Yes.

When you ask to see the source code, the browser shows you the source code. It doesn't show you a serialisation of the current state of the DOM (which is what the DOM Inspector is for).

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205
1

View Source shows you the source code of the site. The exact thing that your browser initially received from the server. Anything happening from then on is modifying the DOM of the loaded document, it's not transforming into source code.

deceze
  • 471,072
  • 76
  • 664
  • 811