1

I am trying to dynamically update the document title from php script in regular intervals, it seems to not be working. I am a beginner to jquery, please help.

 <div id="code" style="border: 1px solid; "></div>
    <script>
     var blink = true;

    setInterval(function(){

    if(blink){
    jQuery('#code').load('test.php', function(result) {
    var theTitle = document.getElementsByTagName("title")[0];   
         theTitle= 'google'+jQuery('#code').html();

    });

        //theTitle.text =document.getElementById('code').value;
        blink = false;
    }else{

     jQuery('#code').load('test.php', function(result) {
    var theTitle = document.getElementsByTagName("title")[0];   
         theTitle= 'yahoo'+jQuery('#code').html();

    });

        blink = true;
    }
    }, 2000);
4

3 に答える 3

1
theTitle.textContent ="what you want"
于 2012-10-05T09:35:21.667 に答える
0

jqueryを使用する場合は、これを試してください:

var blink = true;
setInterval(function(){
    $('#code').load('test.php', function(result) {
         $('title').text(blink ? 'google'+$('#code').html() : 'yahoo'+$('#code').html());
         blink = !blink;
    });
}, 2000);
于 2012-10-05T09:49:28.250 に答える
0

試す -

document.title = "new page title."
于 2012-10-05T09:42:10.653 に答える