我试图在输入类型=“text”控件上使用onkeypress,以便在按下输入按钮时触发一些javascript。它适用于大多数页面,但我也有一些页面带有自定义的.NET控件。.NET在使用Javascript onKeypress之前提交消息
问题是.NET在onkeypress之前提交。有没有人有关于如何首先制造onkeypress火的见解?
如果有帮助,这是我的javascript:
function SearchSiteSubmit(myfield, e)
{
var keycode;
if (window.event)
keycode = window.event.keyCode;
else if (e)
keycode = e.which;
else
return true;
if (keycode == 13)
{
SearchSite();
return false;
}
else
return true;
}
感谢,在onkeypress事件触发上面的函数,然后触发searchsite这是谷歌的自定义搜索引擎代码的适应。所以我认为Google执行搜索的过程可能会比.NET做的更长。 – plntxt 2008-12-09 16:50:09
实际上,我只有onkeypress =“SearchSiteSubmit()”添加return(onkeypress =“return SearchSiteSubmit()”)使其工作。 – plntxt 2008-12-09 17:07:08