IE and WebKit
document.body.innerText
Others:
document.body.textContent
(as suggested by Amr El-Garhi)
Most js frameworks implement the crossbrowser method for this. This is usually done as follows:
text = document.body.textContent || document.body.innerText;
WebKit seems to preserve some formatting with help textContent, while it splits everything into innerText.
source
share