我如何在.load()时更改动态页面标题 [英] How do I change dynamic page title while .load()

查看:117
本文介绍了我如何在.load()时更改动态页面标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#container div中加载内容后如何更改页面标题<title></title>?

How to change my page title <title></title> after content is loaded in #container div?

$(document).ready(function () {
    $("a.view").live('click', function () {
        var id = $(this).data("id");
        $('#container').load("view.php?" + id);
    });
});

如果没有.load(),我可以通过URL获取id来检索它,例如view.php?id=1

If without .load() I retrieve it by get the id via URL, example view.php?id=1

if (isset($_GET['id'])) {
 $pageid = intval($_GET['id']);
 $select = $db->query('SELECT id, title FROM content WHERE id="'.$id.'"');
 $data   = $db->fetch($select);
 $title  = $data['title'];
}

所以在我的header.php中将其命名为<title><?php echo $title; ?></title>

So in my header.php just call it <title><?php echo $title; ?></title>

如果在这种情况下,文件在header.php之后加载,那么如何根据当前的.load("view.php?" + id)动态创建页面标题?

If in this case file is load after header.php so how can I create dynamic my page title according to current .load("view.php?" + id)?

推荐答案

您可以设置 document.title属性:

You can set the document.title property:

document.title = "My new title!";

这篇关于我如何在.load()时更改动态页面标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆