简体   繁体   English

实施也启用了JavaScript的网站的技术

[英]Techniques to implement javascript enabled websites that also run without it

I'm looking for design patterns, frameworks or techniques to implement a web page that fulfills these requeriments: 我正在寻找设计模式,框架或技术来实现可满足这些要求的网页:

  • The web pages are rendered statically at first load, without needing any JavaScript support. 网页在首次加载时是静态呈现的,不需要任何JavaScript支持。
  • If enabled, JavaScript should be used to load new portions of the website when the user tries to follow a link, and change the URL accordingly using the HTML5 history api or equivalent. 如果启用,则当用户尝试访问链接时,应使用JavaScript加载网站的新部分,并使用HTML5历史api或等效的API相应地更改URL。
  • If not available, new pages should be loaded statically by following the links. 如果不可用,则应通过以下链接静态加载新页面。
  • I shouldn't write the code twice, obviously. 显然,我不应该编写两次代码。 This would lead to inconsistencies. 这将导致不一致。

I've been thinking on this problem for a while but I haven't come with an answer. 我已经在思考这个问题了一段时间,但我没有一个答案。

Edit: MVC sounds like a good start to solve this problem, but I definitely want to avoid writing the views code twice. 编辑:MVC听起来是解决此问题的一个好的开始,但我绝对希望避免两次编写视图代码。

This requires backend support, so the techonology of your backend matters. 这需要后端支持,因此后端的技术至关重要。

That said, this sound an awful lot like the rails library Turbolinks: https://github.com/rails/turbolinks/ 也就是说,这听起来很像Rails库Turbolinks: https//github.com/rails/turbolinks/

On the front end alone, supporting JS and non-JS is known as Graceful Degredation and there are lots of articles on it all over the web. 仅在前端,对JS和非JS的支持就被称为Graceful Degredation ,它在网络上有很多文章

If I understand your problem, I think these links will help: 如果我了解您的问题,我认为这些链接会有所帮助:

http://www.implico.pl/lang-en/ajaxgetcontent_dynamic_ajax_website,7.html http://www.implico.pl/lang-en/ajaxgetcontent_dynamic_ajax_website,7.html

http://www.asual.com/jquery/address/ http://www.asual.com/jquery/address/

There is also a github project (browserstate/history.js) to handle this, but I dont post more links, I need reputatión :p 还有一个github项目(browserstate / history.js)处理这个问题,但是我没有发布更多链接,我需要reputatión:p

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM