【问题标题】:setting doc head title on jquery address with wordpress使用 wordpress 在 jquery 地址上设置文档头标题
【发布时间】:2011-10-15 15:35:39
【问题描述】:

我有一个带有 Ajax 深度链接的测试 wordpress 博客。我想做的只是在ajax加载页面或帖子时设置一个新的标题。

通过锚标记属性标题或哈希 url 名称调用它。

任何帮助将不胜感激。

http://missionandromeda.com/test/初始测试页

$("body").append("<img src='loader.gif' id='ajax-loader' style='position: absolute; left: 50%; top: 64%;' />");

var base = 'http://missionandromeda.com/test',
$mainContent = $("#container"),
$ajaxSpinner = $("#ajax-loader"),
$allLinks = $("a"),


$('a:urlInternal').live('click', function(e) {


// Default action (go to link) prevented for comment-related links (which use onclick attributes)
e.preventDefault();

});



$.address.change(function(event) {
    if (event.value) {
        $ajaxSpinner.fadeIn();
        $mainContent
        .empty()
        .load(base + event.value + ' #content', function() {
            $ajaxSpinner.fadeOut();
            $mainContent.fadeIn();
    });
}

var current = location.protocol + '//' + location.hostname + location.pathname;
    if (base + '/' != current) {
    var diff = current.replace(base, '');
    location = base + '/#' + diff;
}
});

【问题讨论】:

    标签: jquery ajax jquery-address


    【解决方案1】:

    仅在 Firefox 中测试过,但在这里可以正常工作:

    $(document).attr('title','Your brand new title here ....');
    

    【讨论】:

      【解决方案2】:

      我会寻找更有活力的东西..反正就是这样

      $('head title').html(data.match('<title>(.+)</title>')[0].replace('<title>','').replace('</title>',''));
      

      【讨论】:

        猜你喜欢
        • 2015-11-14
        • 2020-11-04
        • 2012-12-11
        • 2018-06-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多