开发者

Append URL with .load() - loaded content's id or file name

I am loading conte开发者_运维问答nt into a div, and when loaded I want to change the page's URL to reflect the loaded content. I.E. parent page - http://www.example.com/foo - when content is loaded http://www.example.com/foo#content-1

This code is appending it with "#undefined"

...
var href = $(this).attr('href');
$("#content").load(href, function() {
            window.location.hash = (this).hash;
        });

... I need to target the loaded content's id or url? I would guess url

thanks!


If you want to do that for browser history:

try this plugin: http://benalman.com/projects/jquery-bbq-plugin/

Here is the sample: http://benalman.com/code/projects/jquery-bbq/examples/fragment-basic


on line 4, you are using (this).hash instead of $(this).hash

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜