Results 1 to 2 of 2

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

  1. #1
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,982
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>The Hard Coded Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
    (function(){
    	var millis = 3000, // milliseconds between title changes
    	titles = [ // Configure titles below, original title will be automatically added to the end
    		"This is the Next Title",
    		"And the Next",
    		"The Next After That" // <-- No comma after the last title
    	], count = 0;
    	titles.push(document.title);
    	setInterval(function(){
    		document.title = titles[count % titles.length];
    		++count;
    	}, millis);
    })();
    </script>
    </head>
    <body>
    
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •