其實個網頁不算太複雜, 你用瀏覽器View Source功能已經可以看到Source Code,
除去大部份不相關表格,答案自然出來。 以下節錄自該網頁之code:

<td><label for="txtTest">Type in the box to raise event code message box:</label></td>
<td><input type="text" value="" id="txtTest" style="border: solid 1px Red;"/></td>
..........
window.onload = MyOnLoad;  
function MyOnLoad(){
    var txtBox = xGetElementById('txtTest');                                          
    txtBox.onkeydown=DisplayKeyCode;
}  
function DisplayKeyCode(event){        
    var ev=new xEvent(event);
    alert('Key code: ' + ev.keyCode);
}

TOP

唔記得input text禁enter係按submit掣添

因為而家寫親都disable佢
tuyylihk 發表於 2013-10-20 08:48


form onsubmit="return myFunction();"


function myFunction() {
.......
return false;
}

TOP