服务器端的渐进增强?
目前,我们页面上的许多链接在页面加载时都会更改为 href="javascript:void(0);"
,但如果您不耐烦(就像大多数用户一样),您可以先点击这些链接页面加载并登陆到更笨重的、非 javascript、非 ajax 页面。
这些天我经常考虑渐进式增强,我预测我们的大多数用户将启用 JavaScript(还没有数据,我们还没有启动 alpha)
生成一些指标是一个坏主意吗用户为会话启用了 javascript,然后提供假定 javascript 的页面? (即让服务器从头开始放置 href="javascript:void(0);"
)
Currently many of the links on our pages get changed to href="javascript:void(0);"
on pageload, but if you're impatient (as most users are) you can click the links before the page loads and land on the clunkier, non-javascript, non-ajax pages.
I'm thinking about progressive enhancement a lot these days, and I predict the majority of our users will have javascript enabled (no data yet, we havn't yet launched alpha)
Is it a bad idea to generate some indicator that a user has javascript enabled for the session, and then serve pages that assume javascript? (ie. have the server put href="javascript:void(0);"
from the start)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么不直接这样做呢?
return false
告诉浏览器不要继续处理 href 中的 url。现在js访问者得到了精美的js,非js用户则默默回退; 并且无需更改页面加载上的链接。
Why not just do this?
return false
tells the browser not to carry on to the url in the href.Now js visitors get fancy js, and non-js users fall back silently; and there is no need for changing links on pageload.
您是否对负载进行渐进增强? 您可以尝试将其移至 DOMReady(跨浏览器版本)。
Do you do your progressive enhancement on load? You could try to move it to (a cross-browser version of) DOMReady.
您不能将其委托给文档以保持 HTML 干净吗?
例如,在 jQuery 中:
Couldn't you delegate this to the document, to keep your HTML clean?
For example, in jQuery: