SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2007
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make page title, auto refresh every x seconds (using javascript/jquery/others)

    I have a php file lets say file1.php, that printing a variable, its dynamic numbers output that already always increasing, like private message numbers that coming or others :

    PHP Code:
    <?php
    echo $variable
    ?>


    i want to put that variable output, in another files page title, lets say file2.php or file3.html,
    in the front of the another files page titles, and auto refresh every x seconds, maybe like this :

    (1) - another text in the page title
    after x seconds, get a private message
    (2) - another text in the page title
    after another x seconds, get another private message
    (3) - another text in the page title




    or its ok if just like this, only the variable, without the another text in the page title
    (1)




    please share your knowledge to make it, maybe using javascript, jquery or others
    Make the world better

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by basketmen View Post
    i want to put that variable output, in another files page title, lets say file2.php or file3.html,
    in the front of the another files page titles, and auto refresh every x seconds, maybe like this:



    after x seconds, get a private message


    after another x seconds, get another private message
    A server cannot send information to a client. What has to happen is for the client to ask for information from the server, which can be where the client can use Ajax to poll the server on a regular basis.

    For example, you can update the title to show the time/date with:

    Code javascript:
    window.setInterval(function () {
        var title = document.head.getElementsByTagName('title')[0];
        title.innerHTML = new Date();
    }, 1000);

    In a similar manner, perhaps every 60 seconds or so, you can perform an Ajax request of the server for private messages or other information.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •