开发者

hashchange, pushState with jQuery BBQ -- Adding characters to URL

I have a Fiddle to look at. The hashchange will not work in jsFiddle, but you can at 开发者_如何学JAVAleast see the code:

http://jsfiddle.net/LpgFt/

When I click on links the URL changes to:

index.html#url=%23about-us

rather than:

index.html#about-us

Any ideas what I'm doing wrong?


you can change your code to $.bbq.pushState({ href });

Check out this fiddle (not in iframe) ... and the actual fiddle

Updated code

$('a').click(function(){
  var href = $(this).attr( "href" );
  $.bbq.pushState({ href });
  return false;
});

 $(window).bind( "hashchange", function(e) {
    var url = e.getState( "url" );
    $("a").each(function(){
      var href = $(this).attr( "href" );
    });
  });

  $(window).trigger( "hashchange" );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜