Anchors in links

拈花ヽ惹草 提交于 2019-12-05 13:09:32

I had a test here http://bl.ocks.org/abernier/raw/3183257/

It appears that YES:

  • anchors can be used with pushState-enabled browsers : http://bl.ocks.org/abernier/raw/3183257/product1.html#special-offer
  • while for IE<10, it is converted to http://bl.ocks.org/abernier/raw/3183257/#product1.html eg: without #special-offer

The only thing I had to take care about was to disable anchors for hashes-based history browsers, by:

if (!Backbone.history._hasPushState) {
  $('body').delegate('a[href^=#]', 'click', function (e) {
    e.preventDefault();
  });
}

Backbone has a very customizable use of hash URL fragments within its modules Router and History.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!