0

How to convert content of HTML page to single string using JavaScript?

my HTML page contains labels, text boxes

Thanks in advance........

1
  • What do you exactly mean? The string contains the whole webpage or the information contained in labels, text boxes? Commented Jun 8, 2011 at 6:46

3 Answers 3

1

You can display like this in script

<script>
var content = document.body.innerHTML;
alert (content);
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

This will output to console the whole content of the body tag of your page.

console.log(document.body.innerHTML);

Comments

0

This will get you the entire page between and including the <html> tags:

document.getElementsByTagName('html')[0].outerHTML

Comments

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.