function locate(){ var input= document.getElementById("no").value; document.getElementById("no").focus(); var reg = /^[1-9]\d{4,9}$/; if(!reg.test(input)){ alert("非法的QQ号码"); document.getElementById("no").select(); return; } document.getElementById("ifrHtmlEditor").src = "http://wpa.qq.com/msgrd?V=1Uin="+input+"Site=www.qq.comMenu=yes"; document.getElementById("no").select(); } function document_onkeyup() { if (event.keyCode==13) locate(); if (event.keyCode==8) return; if( (event.keyCode >= 47 && event.keyCode <= 57) || (event.keyCode >= 0x60 && event.keyCode <= 0x69) ) event.returnValue = true; else event.returnValue =false; } function window_onload() { document.getElementById("no").focus(); } [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]