Jump to content

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


Recommended Posts

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
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

You need to use AJAX to poll the server every x amount of seconds for new messages, then update the value of the JavaScript document.title property. The jQuery documentation has plenty of AJAX examples, but if you get stuck post your progress and we'll give you a hand.

 

Edit

 

I'm not too sure what you were referring to with the access across different files, but you shouldn't be refreshing the page. That will annoy your users immensely! As I said, use a client-side scripting (JS) to poll the server for the updated number and dynamically change it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.