ÐèҪдһ¸öjs·½·¨£ºescKeyPress()¡£Õâ¸ö·½·¨ÓÃÓÚÄ£ÄⰴϼüÅÌÉϵÄESC¼ü£¬ÎÒÏÖÔÚÓÐÒ»¸öÄ£ÄâÊó±ê×ó¼üµ¥»÷µÄjs·½·¨£¬JScript code:
function doClick(linkId){
var fireOnThis = document.getElementById(linkId);
if (document.createEvent)
{
var evObj = document.createEvent('MouseEvents');
evObj.initEvent( 'click', true, false );
fireOnThis.dispatchEvent(evObj);
}
else if (document.createEventObject)
{
fireOnThis.fireEvent('onclick');
}
}
ÊÇ´ÓÍøÉÏÕҵģ¬µ«ÊDZ¾ÈËÌ«²Ë£¬ËÑÁË°ëÌìҲŪ²»µ½Ä£Äâ¼üÅ̵ã»÷µÄjs·½·¨£¬ÇëÇó´óϺ°ï棡£¡
onkeypress
Õâ¸öʼþÔÚÓû§°´Ï²¢·Å¿ªÈκÎ×ÖĸÊý×Ö¼üʱ·¢Éú¡£ÏµÍ³°´Å¥£¨ÀýÈ磬¼ýÍ·¼üºÍ¹¦Äܼü£©ÎÞ·¨µÃµ½Ê¶±ð¡£
onkeyup
Õâ¸öʼþÔÚÓû§·Å¿ªÈκÎÏÈÇ°°´ÏµļüÅ̼üʱ·¢Éú¡£
onkeydown
Õâ¸öʼþÔÚÓû§°´ÏÂÈκμüÅ̼ü£¨°üÀ¨ÏµÍ³°´Å¥£¬Èç¼ýÍ·¼üºÍ¹¦Äܼü£©Ê±·¢Éú¡£
ʾÀý£º
function document.onkeydown()
{
if ( event.keyCode=='39' ) //->ÓÒ¼ýÍ·
{
window.open("http://www.163.com");
}
}
function document.onkeypress()
{
if ( event.keyCode=='43' )
{
alert( 'ÄãÊäÈëÁ˼üÅÌµÄ ¡° + ¡± ¼ü');
ÎÒҪʵÏÖµÄͼÏñƽÒÆÒªÏëµç×ÓµØͼÖÐÄÇÑù£¬ÔÚÒ»¸ö¹Ì¶¨µÄÇøÓòÄÚ½øÐÐËõ·ÅºÍƽÒÆ£¬³¬³öÕâ¸öÇøÓòÄڵIJ¿·ÖÓ¦¸Ã¿´²»µ½ÁË
Õâ¸öÒ»ÏÂ˵²»Çå³þ£¬ÄãËÑË÷ÏÂÕâÀàµÄJSЧ¹ûÎļþ£¬Ó¦¸ÃÓеÄ
asdads
²»ÖªµÀJQUERYÓÐûÓÐÕâÖÖ²å¼þ
......