我跟秋紅正 一起學 javascript objec宣告


function toggle(textbar,textbardiv,eventdiv)

{

this._onfocus=false;    

this.textbar = textbar;

this.textbardiv=textbardiv;

this.eventdiv=eventdiv;

thisClcss=this;





this.toggleVisibility=function ()

{

thisClcss._onfocus=false;

if(thisClcss.textbardiv.style.display=="")

{

thisClcss.textbardiv.style.display="none";

thisClcss.textbardiv.style.position="absolute"; 

thisClcss.textbar.style.display="";

thisClcss.textbar.value=thisClcss.textbardiv.innerHTML;

}

} 



this.togglehidden=function ()

{

if(!thisClcss._onfocus)

{    

thisClcss.textbardiv.style.display="";

thisClcss.textbar.style.display="none";

thisClcss.textbardiv.innerHTML=thisClcss.textbar.value;

}

} 



this.togglehidden1=function ()

{

thisClcss.textbardiv.style.display="";

thisClcss.textbar.style.display="none";

thisClcss.textbardiv.innerHTML=thisClcss.textbar.value;    

} 



this.t_onfocus = function ()

{

thisClcss._onfocus=true;    

}





this.textbar.onblur=this.togglehidden1;

this.textbar.onfocus=this.t_onfocus;

this.eventdiv.onmouseout=this.togglehidden;

this.eventdiv.onmouseover=this.toggleVisibility;



thisClcss.togglehidden();

}



var texttest = new  toggle(document.getElementById('textfield'),document.getElementById('345'),document.getElementById('123'));

留言

這個網誌中的熱門文章

電腦網路project