使用 JavaScript 禁用 ASP.NET 3.5 应用程序中的提交按钮会破坏 BlackBerry 提交
以下代码用于在单击“提交”按钮后禁用该按钮。这在桌面浏览器和大多数 BlackBerry 移动浏览器上效果很好。
Submit.Attributes.Add("onclick", "javascript:this.disabled=true;" +
ClientScript.GetPostBackEventReference(Submit, null));
不幸的是,当使用 BlackBerry Storm 时,单击提交按钮会导致设备重新加载页面。如果我删除此代码,Storm 浏览器会正常提交页面。当浏览器能够禁用该按钮但又不想影响不支持 JavaScript 的浏览器时,我需要禁用该按钮。
我意识到我可以添加 jQuery 框架并仅附加事件客户端,但我试图寻找最简单的修复(读取最少侵入性),因为这是一个遗留应用程序。有什么建议吗?
The following code is being used to disable a Submit button once it has been clicked. This works great on desktop browsers and most BlackBerry mobile browsers.
Submit.Attributes.Add("onclick", "javascript:this.disabled=true;" +
ClientScript.GetPostBackEventReference(Submit, null));
Unfortunately, when using a BlackBerry Storm clicking the submit button causes the device to just reload the page. If I remove this code the Storm browser submits the page just fine. I need to disable the button when the browser is capable of doing so but do not want to affect browsers that are not JavaScript capable.
I realize I could add the jQuery framework and only attach the event client side, but am trying to look for the simplest fix (read least intrusive) as this is a legacy application. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你可以这样做 - 我已经很长时间没有这样做了,并且一些HttpCapability API 已被标记为已过时,但通常您可以通过执行以下操作来检测浏览器是否支持 javascript:
I believe you can do it this way - I haven't done this in a long time and some of the HttpCapabilities API has been tagged as obsolete, but in general you can detect if the browser supports javascript by doing this: