VaR $ = function (ID ){
Return document. getelementbyid (ID );
};
VaR textbox = function (OBJ ){
VaR text = Document. createelement ("input ");
Text. type = "text ";
Text. onkeypress = function (){
For (VAR I = 0; I <obj. Code. length; I ++ ){
If (event. keycode = obj. Code. charcodeat (I )){
Return true;
}
}
Return false;
}
OBJ. parentdiv. appendchild (text );
Return text;
};
VaR ad = function (OBJ ){
VaR mydiv = Document. createelement ("Div ");
Mydiv. style. width = "200px ";
Mydiv. style. Height = "300px ";
Mydiv. style. backgroundcolor = "red ";
Mydiv. style. zindex = 1;
Mydiv. style. Position = "absolute ";
VaR myimg = Document. createelement ("IMG ");
Myimg. style. width = "200px ";
Myimg. style. Height = "300px ";
Myimg. src = obj. imgurl;
If (obj. Float = "Left "){
Mydiv. style. Left = "30px ";
Mydiv. style. Top = "60px ";
} Else {
Mydiv. style. Right = "30px ";
Mydiv. style. Top = "60px ";
}
If (obj. isclose ){
VaR myclose = Document. createelement ("Div ");
Myclose. style. width = "13px ";
Myclose. style. Height = "13px ";
Myclose. style. zindex = 1;
Myclose. style. backgroundcolor = "red ";
Myclose. style. Position = "absolute ";
Myclose. style. Left = parseint (mydiv. style. width)-parseint (myclose. style. width) + "PX ";
Myclose. style. Top = parseint (mydiv. style. Height)-parseint (myclose. style. Height) + "PX ";
Myclose. innerhtml = "X ";
Myclose. onclick = function (){
Mydiv. style. Display = "NONE ";
}
Mydiv. appendchild (myclose );
}
Mydiv. appendchild (myimg );
OBJ. parentdiv. appendchild (mydiv );
}
JS file/
Page //
<SCRIPT type = "text/JavaScript">
Window. onload = function (){
VaR TB = new Textbox ({
Code: "123456 ",
Parentdiv: $ ("mydiv ")
});
VaR ad = new ad ({
Parentdiv: $ ("mydiv "),
Imgurl: "images/0.jpg ",
Isclose: True,
Float: "left"
});
}
</SCRIPT>