2

I am new to JavaScript, and I want to know if there is a way, or ways, to get the whole text from a web-page, which means the text a person can read on a webpage (excluding any images' text).

1 Answer 1

4

You should be able to use:

document.body.innerText;  
Sign up to request clarification or add additional context in comments.

4 Comments

Hi, Thanks for ur quick reply this is working but i m getting some squire boxes type text. how can i remove these..
share the url where you are getting square boxes.
If you are talking about the square boxes on the botom of SO. then these are html entries there.
I am using below scrip String s = "var allLinks = document.getElementsByTagName('*'); " + "var str = document.body.innerText.replace(/\\s*/g, ' ');" + //.replace(/\\s*/g, ' ');" //replace(/</?[a-zA-Z0-9]+>|<[a-zA-Z0-9]+\\s*/>|\r?\\n/g,' ') "alert(str);"; And at yahoo.com I m getting the [][][][][] type boxes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.