服务器端的渐进增强?

发布于 2024-07-21 07:11:05 字数 346 浏览 9 评论 0原文

目前,我们页面上的许多链接在页面加载时都会更改为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

辞旧 2024-07-28 07:11:05

为什么不直接这样做呢?

<a href="oldversion.htm" onclick="...something useful......; return false;">link</a>

return false 告诉浏览器不要继续处理 href 中的 url。

现在js访问者得到了精美的js,非js用户则默默回退; 并且无需更改页面加载上的链接。

Why not just do this?

<a href="oldversion.htm" onclick="...something useful......; return false;">link</a>

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.

变身佩奇 2024-07-28 07:11:05

您是否对负载进行渐进增强? 您可以尝试将其移至 DOMReady(跨浏览器版本)。

Do you do your progressive enhancement on load? You could try to move it to (a cross-browser version of) DOMReady.

糖果控 2024-07-28 07:11:05

您不能将其委托给文档以保持 HTML 干净吗?

例如,在 jQuery 中:

$( document )
    .click( function(){ return false })
    .ready( function(){ $( this ).unbind( "click" ) } )

Couldn't you delegate this to the document, to keep your HTML clean?

For example, in jQuery:

$( document )
    .click( function(){ return false })
    .ready( function(){ $( this ).unbind( "click" ) } )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文