服务器端的渐进增强?

时间:2022-12-08 08:15:41

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.

目前,我们网页上的许多链接都更改为href =“javascript:void(0);”在页面加载,但如果你不耐烦(因为大多数用户),你可以在页面加载之前单击链接并登陆clunkier,非javascript,非ajax页面。

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)

我现在正在考虑逐步增强,我预测我们的大多数用户都会启用javascript(还没有数据,我们还没有启动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)

生成一些用户为会话启用了javascript的指标,然后提供假设javascript的页面是不是一个坏主意? (即从一开始就让服务器放入href =“javascript:void(0);”)

3 个解决方案

#1


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.

return false告诉浏览器不要进入href中的url。

Now js visitors get fancy js, and non-js users fall back silently; and there is no need for changing links on pageload.

现在js访客得到了花哨的js,非js用户默默地退缩;并且无需更改页面加载链接。

#2


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

你是否在加载时进行逐步增强?您可以尝试将其移动到(DOM浏览器版本)DOMReady。

#3


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

你不能将它委托给文件,以保持你的HTML清洁吗?

For example, in jQuery:

例如,在jQuery中:

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

#1


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.

return false告诉浏览器不要进入href中的url。

Now js visitors get fancy js, and non-js users fall back silently; and there is no need for changing links on pageload.

现在js访客得到了花哨的js,非js用户默默地退缩;并且无需更改页面加载链接。

#2


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

你是否在加载时进行逐步增强?您可以尝试将其移动到(DOM浏览器版本)DOMReady。

#3


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

你不能将它委托给文件,以保持你的HTML清洁吗?

For example, in jQuery:

例如,在jQuery中:

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