js實現文字框中內容的放大顯示

來源:互聯網
上載者:User

標籤:

<!doctype html><html><head><meta charset="utf-8"><title>文字框放大</title><script>function $(id){return document.getElementById(id);}function showBigInfo(obj){var bigObj;if(!$("bigInfo")){bigObj=document.createElement("span");bigObj.setAttribute("id","bigInfo");bigObj.style.position="absolute";bigObj.style.border="1px solid #F93";bigObj.style.borderRadius="2px";bigObj.style.color="red";bigObj.style.fontSize="26px";bigObj.style.fontWeight="bold";bigObj.style.padding="4px";bigObj.style.display="none";document.body.appendChild(bigObj);obj.onblur=function(){$("bigInfo").style.display="none";}obj.onfocus=function(){$("bigInfo").style.display="block";}}else{bigObj=$("bigInfo");}bigObj.style.display="block";var str="";var info=obj.value;for(var i=0;i<info.length;i+=4){str+=info.substr(i,4)+" ";}bigObj.innerHTML=str; if(obj.offsetTop<50){ //放大框在下方顯示bigObj.style.top=(obj.offsetTop+obj.offsetHeight+2)+"px";}else{ //放大框在上方顯示bigObj.style.top=(obj.offsetTop-bigObj.offsetHeight-2)+"px";}bigObj.style.left=(obj.offsetLeft+obj.offsetWidth/2-bigObj.offsetWidth/2)+"px";}</script></head><body><br /><br /><br /><br /><br /><br /><center>請輸入社會安全號碼碼:<input type="password" onKeyUp="showBigInfo(this)" maxlength="18" size="30"/><br />請輸入社會安全號碼碼:<input type="password" onKeyUp="showBigInfo(this)" maxlength="18" size="30"/><br />請輸入社會安全號碼碼:<input type="password" onKeyUp="showBigInfo(this)" maxlength="18" size="30"/></center></body></html>

 

js實現文字框中內容的放大顯示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.