Innertext and innerhtml

Source: Internet
Author: User

Innerhtml and innertext are often used to attack the system. What is the difference between them?

 <  Html  >   <  Head  >    <  Title  > New Document </  Title  >    <  Meta  Name  = "Generator" Content  = "Editplus"  >    <  Meta  Name  = "Author"  Content  = ""  >    <  Meta  Name  = "Keywords"  Content  = ""  >   <  Meta  Name  = "Description"  Content  = ""  >   </  Head  >   <  Body  >    <  Table  ID  = "Curedata" >      <  Tr  >          <  TD  > A </  TD  >          <  TD  > AA </  TD  >          < TD  > Aaa </  TD  >      </  Tr  >      <  Tr  >          <  TD  > B </  TD  >         <  TD  > Bb </  TD  >          <  TD  > Bbb </  TD  >      </  Tr  >    </  Table >        <  Input  Type  = "Button"  Value  = 'Display'  ID  = 'Btn'  Onclick  = "Getfirstrowinfo ();"  />   </  Body  >  </  Html >  <  Script  Type  = 'Text/JavaScript'  >      Function  Getfirstrowinfo (){  VaR  TRS  =  Document. getelementbyid (  ' Curedata  '  ). Getelementsbytagname (  '  Tr  '  );  VaR  Firstid1  =  TRS [  1 ]. Cells [  0  ]. Innertext;  VaR  Firstid2  =  TRS [  1  ]. Cells [  0  ]. Innerhtml; alert (firstid1 +  "  ... 1  "  ); Alert (firstid2  +  "  ... 2  "  );}  </  Script  > 

 

Click:

① In IE8, the display effect is:

② In Chrome, the display effect is:

③ Show the effect under Firefox:

 

This is the difference.

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.