开发者

Adding title to page with instant jQuery search script

I have a Google Instant style search script written in jQuery. When the user queries, #SEARCHTERM is added onto my page URL. I was wondering how I could add the users query into the title of my page so it would be "SEARCHTERM - My Search Script"

Here is my current code:

$(document).ready(function(){
    $("#search").keyup(function(){
        var search=$(this).val();
        var keyword=encodeURIComponent(search);
        var yt_url='search.php开发者_如何学JAVA?q='+keyword+'&category=web';
        window.location.hash=keyword;

        $.ajax({
            type:"GET",
            url:yt_url,
            dataType:"html",
            success:function(response){
                $("#result").html(response);
            }
        });
    });
});


Assign title with: document.title

document.title = $(this).val() + " - My Search Script";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜