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