【问题标题】:Make JS change urls (using hashtag) when changing page更改页面时使 JS 更改 url(使用主题标签)
【发布时间】:2012-01-06 12:46:45
【问题描述】:

我正在使用这个 javascript 代码来动画和加载我的网站!

$('.down-trigger').on('click', function () {
var toLoad = $(this).attr('href')+' #container';
     $('#container').attr('id','to-go');
     $('#wrapper').append('<div id="newcontainer"/>');
     $('#newcontainer').load(toLoad, function () {
       $('#newcontainer').append($('#container').children()).css({'position': 'absolute', 'top': '696px'});
       $('#to-go, #newcontainer').animate({top:'-=691'},600, function () {
         $('#to-go').remove();
         var lastchild = $('.page:last-child'); // ignore these lines
         var found = lastchild.find('div.slide'); // this one
         if (found.length == 0) { lastchild.remove(); } // and this one
         carousels(); // and this one too
       });
     $('#container').remove();
     $('#newcontainer').attr('id','container');
     searchform(); // these two lines can be ignored too
     triggers(); // this is the second line to ignore
   });
   return false;
});`

当用户点击链接时,你们能帮忙更改网址吗?

我知道我必须使用诸如 window.location.hash 之类的东西,但我真的不知道从哪里开始。

谢谢。

【问题讨论】:

    标签: javascript jquery url url-rewriting


    【解决方案1】:
    window.location.href = 'myNewUrl.html';
    

    【讨论】:

    • 很难判断你的代码到底发生了什么......你会是最好的判断,但你把它放在你准备好实际更改的代码中的任何地方下一页。
    猜你喜欢
    • 1970-01-01
    • 2011-12-12
    • 2011-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    相关资源
    最近更新 更多