4

我当前的项目是编写一个与现有桌面应用程序等效的 Web 应用程序。

在桌面应用程序的工作流程中的某些点,用户可能会单击一个按钮,然后显示一个要填写的表单。即使应用程序显示表单需要一点时间,专家用户也知道该表单将是什么并且会开始打字,知道应用程序会“赶上他们”。

在 Web 应用程序中不会发生这种情况:当用户单击链接时,他们的击键将丢失,直到显示下一页上的表单。有没有人有任何防止这种情况的技巧?我是否必须放弃使用单独的页面并使用 AJAX 将表单嵌入到页面中,使用GWT之类的东西,或者仍然会有丢失击键的问题?

4

4 回答 4

6

在页面加载、javascript 被处理并且文本字段被聚焦之前,击键不会有效果。

基本上你真正要问的是;如何加快 Web 应用程序以增加响应时间?您的答案是 AJAX!

仔细考虑应用程序中最常见的操作,并使用 AJAX 最大限度地减少网页的重新加载。记住,不要过度使用 AJAX。使用过多的 javascript 会阻碍可用性,就像它可以提高可用性一样。

相关阅读材料:

于 2008-09-14T22:43:40.790 回答
1

Perhaps I am under-thinking the problem but I'll throw this out there... You could just put your form inside a hidden div or similar container that you show (perhaps give it a modal look/behavior?) on the click event of the link. That way the form is already loaded as part of the page. It should appear almost instantly.

You can find modal div tutorials all over the place, shouldn't be too tricky. If you're using ASP.NET there's even one included in Microsoft's AJAX library.

于 2008-09-16T13:46:27.180 回答
0

AJAX 或插件是您唯一的机会。

于 2008-09-14T22:36:50.073 回答
0

我认为做你想做的事情会很困难。我认为真正的问题是新页面加载时间过长。您应该考虑缓存页面或对静态组件(例如图片等)进行部分缓存,以改善加载时间或预加载页面并使其不可见。(有关一些想法,请参阅更多可用表单的简单技巧)

对于编码选项,您可以使用 javascript 来捕获击键(请参阅检测各种击键

<html><head>
<script language=javascript>
IE=document.all;
NN=document.layers;
kys="";
if (NN){document.captureEvents(Event.KEYPRESS)}
document.onkeypress=katch
function katch(e){
if (NN){kys+=e.which}
if (IE){kys+=event.keyCode}
document.forms[0].elements[0].value=kys
}
</script>
</head>
<body>
<form><input></form>
</body>
</html>

您需要保存它们,然后在控制从当前页面传递后将它们转移到新页面。(请参阅在关闭浏览器或退出页面时保存更改

有关在各种浏览器中检测击键问题的一些一般信息,请查看Javascript-Detecting keystrokes

于 2008-09-14T22:54:13.027 回答