Rainmaker February 2016

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?

Answers


Quentin February 2016

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


deceze February 2016

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.

Post Status

Asked in February 2016
Viewed 3,769 times
Voted 13
Answered 2 times

Search




Leave an answer