Rainmaker
Rainmaker

Reputation: 103

JavaScript document.write not appearing in page source

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?

Upvotes: 0

Views: 283

Answers (2)

deceze
deceze

Reputation: 522015

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.

Upvotes: 1

Quentin
Quentin

Reputation: 943157

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).

Upvotes: 3

Related Questions