HTML Tag completion...

Source: Internet
Author: User

<! --
This job is generally processed in the background, but the JS Code It's easy to change to several languages...
-->
<Textarea>
<Table width = "100%" cellspacing = "0" cellpadding = "0">
<Tr>
<TD> & nbsp; </TD>
<TD> & nbsp; </TD>
</Tr>
<Tr>
<TD> & nbsp; </TD>
<TD>
<Table width = "100%" cellspacing = "0" cellpadding = "0">
<Tr>
<TD> & nbsp; </TD>
<TD>

<Table width = "100%" cellspacing = "0" cellpadding = "0">
<Tr>
<TD> </TD>
<TD> & nbsp; </TD>
</Tr>
<Tr>
<TD> <Param/> & nbsp; </TD>
<TD> & nbsp; </TD>

</Tr>
<Tr>
<TD> </font> & nbsp; </TD>
<TD> & nbsp; </TD>

</Tr>
</Textarea>
<Textarea style = "width: 600px; Height: 300px;">
</Textarea>
<SCRIPT type = "text/JavaScript">
VaR replenishhtml = function (string ){
VaR list = [];
VaR htmlpattern =/<(\/?) (?! (? : IMG | Param | link | base) \ B) ([A-Za-Z] +) \ B/g;

While (htmlpattern. Test (string )){
If (Regexp. $1 ){
VaR temp = '';
For (VAR I = List. length, L = I; I>-1; I --){
If (list [I] === Regexp. $2 ){
Temp = '<\/' + list. splice (I, list. Length-I). Reverse (). Join ('> <\/') + '> ';
Break;
}
}
If (I =-1) temp = '<' + Regexp. $2 + '> <\/' + Regexp. $2 + '> ';
String = Regexp. leftcontext + temp + Regexp. rightcontext. Slice (1 );
Htmlpattern. lastindex = Regexp. leftcontext. Length + temp. length;
} Else {
List. Push (Regexp. $2 );
}
}
If (list. length) string = string + '<\/' + list. splice (0, list. length ). reverse (). join ('> <\/') + '> ';
Return string;
};

Window. onload = function (){
Document. getelementsbytagname ('textarea ') [1]. value = replenishhtml (document. getelementsbytagname ('textarea') [0]. value );
};
</SCRIPT>

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.