SPAN extension Library [unfinished]

Source: Internet
Author: User

/*
Extended Library source code
Myex. js
*/
VaR myex = {};
Myex. init = function (){
Ss = Document. getelementsbytagname ("span ");
For (I = 0; I <ss. length; I ++ ){
If (ss [I]. myex ){
Ss [I]. attachevent ("onclick", function (){
VaR oo = event. srcelement;
VaR ext = oo. myex;

If (EXT = "selectex "){
VaR o_myselectex = Document. getelementbyid ("_ myselectex ");

If (! O_myselectex ){
O_myselectex = Document. createelement ("select ");
O_myselectex.id = "_ myselectex ";

O_myselectex.style.position = "absolute ";
O_myselectex.style.top = oo. offsettop;
O_myselectex.style.pixelleft = oo. offsetleft
O_myselectex.style.width = oo. offsetwidth;

O_myselectex.style.visibility = "visible ";
OO. style. Visibility = "hidden ";
/*
O_option = Document. createelement ("option ");
O_option.innertext = oo. innertext;
O_myselectex.options.appendchild (o_option );

O_option = Document. createelement ("option ");
O_option.innertext = "paste it into the notepad and save it as htm. The effect is-12-29 ";
O_myselectex.options.appendchild (o_option );
*/
If (oo. xmlsrc ){
Try {/*
VaR xml = eval (oo. xmlsrc );
VaR xmlnode = oo. xmlnode;
XML. s
*/

} Catch (e ){}
}
Document. Body. appendchild (o_myselectex );
O_myselectex.focus ();

O_myselectex.attachevent ("onblur", function (){
VaR es = event. srcelement;
// If a project exists in the SELECT statement, the value of the updated span is the value of the currently selected project.
If (ES. Options. Length) {oo. innertext = es. Options [es. selectedindex]. innertext ;}
Es. style. Visibility = "hidden ";
OO. style. Visibility = "visible ";
Es. removenode (true );
}
);
}
}
If (EXT = "textex "){
VaR o_mytextex = Document. getelementbyid ("_ mytextex ");

If (! O_mytextex ){
O_mytextex = Document. createelement ("input ");
O_mytextex.id = "_ mytextex ";

O_mytextex.type = "text ";
O_mytextex.style.position = "absolute ";
O_mytex.style.top = oo. offsettop;
O_mytextex.style.pixelleft = oo. offsetleft
O_mytex.style.width = oo. offsetwidth;

O_mytextex.style.visibility = "visible ";
OO. style. Visibility = "hidden ";

O_mytextex.value = oo. innertext;

Document. Body. appendchild (o_mytextex );
O_mytextex.focus ();
O_mytextex.select ();

O_mytextex.attachevent ("onblur", function (){
VaR es = event. srcelement;
OO. innertext = es. value;
Es. style. Visibility = "hidden ";
OO. style. Visibility = "visible ";
Es. removenode (true );
}
);
}
}
}
);
}
}
}
Myex. INIT ();

// Configure //---------------------------------------------------------------------------------------------------------------
Instance application:
// Configure //---------------------------------------------------------------------------------------------------------------

<HTML>
<Head>
<Title> myex demo </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<SCRIPT>
// Var xml = f. xmldom ("http: // 127.0.0.1/user. xml ")
</SCRIPT>
</Head>

<Body>

<Span myex = "selectex" xmlsrc = "XML" xmlnode = "// root/"> paste it into the notepad and save it as htm. The effect is-12-29. </span>

<Span> paste it to the notepad and save it as htm. The effect is-12-29. </span> <br>

<Span myex = "selectex"> paste it to the notepad and save it as htm. The effect is-12-29. </span>

<Span myex = "selectex"> paste it to the notepad and save it as htm. The effect is-12-29. </span> <br>

<Span myex = "textex"> paste it to the notepad and save it as htm. The effect is-12-29. </span>

</Body>
<SCRIPT src = "myex. js"> </SCRIPT>

</Html>

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.