Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get body tag value from website [closed]

I need to fetch body tag from the url which i open. I am using following code but it is not working. Please suggest.

document.getElementsByTagName('body')[0].innerHTML;

Thanks Tanu

like image 801
Tanu Garg Avatar asked Jan 23 '12 13:01

Tanu Garg


People also ask

What is the closing body tag of website?

The basic tag is written like this <body> </body> , with the document's content inserted between the opening and closing tags. On any normal-sized HTML document, you'll usually see the opening tag ( <body> ) near the top of the document and the closing tag ( </body> ) near the bottom.

How do I get all the elements in a page?

Finding HTML Elements by CSS Selectors If you want to find all HTML elements that match a specified CSS selector (id, class names, types, attributes, values of attributes, etc), use the querySelectorAll() method. This example returns a list of all <p> elements with class="intro" .

What is displayed in the body tag?

The <body> tag defines the document's body. The <body> element contains all the contents of an HTML document, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.

Can I have 2 bodies in HTML?

The <body> HTML element represents the content of an HTML document. There can be only one <body> element in a document.


1 Answers

Copy below code in url navigation bar. See, whole body content alerted.

javascript:(alert(document.body.innerHTML));

Its means you can get the body content by just body.innerHTML. you don't require to use getElementsByTagName.

like image 191
Umesh Patil Avatar answered Oct 09 '22 04:10

Umesh Patil