Get page document content with JavaScript

Source: Internet
Author: User

The document object of JavaScript contains the actual contents of the page, so the document object can be used to get the page content, such as the page title, individual form values.

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>JS Basics</title>6 7 </Head>8 9 <Body>Ten <P>I. Getting page titles with document objects</P> One <HR/> A <P>Two. Use document to access two of forms</P> -  - <P>First, the value of a text box</P> the  - <formname= "Textform"> -     <inputname= "Textname"type= "text"value= "Please enter text"/> - </form> + <P>The second one, the value of the button</P> -  + <formname= "SubmitForm"> A     <inputname= "Submitname"type= "Submit"value= "Submit in first form"/> at </form> - <HR/> - <P>The following is the value obtained</P> - <TableBorder= "1"cellspacing= "4"cellpadding= "2"> -     <TR> -         <TD>The title that gets to this page is:</TD> in         <TD> <b><Script>document.write (document.title)</Script></b></TD> -     </TR> to     <TR> +         <TD>This page contains the forms:</TD> -         <TD><b><Script>document.write (document.forms.length)</Script></b></TD> the     </TR> *     <TR> $         <TD>Gets the value to the text box:</TD>Panax Notoginseng         <TD><b><Script>document.write (Window.document.textform.textname.value)</Script></b></TD> -     </TR> the     <TR> +         <TD>Gets the value of the button:</TD> A         <TD><b><Script>document.write (Window.document.submitform.submitname.value)</Script></b></TD> the     </TR> +  - </Table> $  $ </Body> - </HTML>

Get page document content with JavaScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.