Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
How to make page title, auto refresh every x seconds (using javascript/jquery/others)
Old 05-07-2012, 03:01 AM How to make page title, auto refresh every x seconds (using javascript/jquery/others)
Skilled Talker

Posts: 90
Name: syu
Trades: 0
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 :

Quote:
(1) - another text in the page title
after x seconds, get a private message
Quote:
(2) - another text in the page title
after another x seconds, get another private message
Quote:
(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
Quote:
(1)




please share your knowledge to make it, maybe using javascript, jquery or others
__________________
Lets help each other
basketmen is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-07-2012, 04:09 AM Re: How to make page title, auto refresh every x seconds (using javascript/jquery/oth
lizciz's Avatar
Super Spam Talker

Posts: 845
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Well, you'll have to use javascript in order to change anything once the page is loaded. jQuery is also javascript, it's just a library that makes things easier.

Just changing the title is no big deal. If you want it to change upon some external events (like getting a PM) you'll have to include some ajax, that periodically (like every 10 seconds or so) calls some resource (like a php script) on the server to check if there are any new PM.

Ajax is pretty darn easy using jQuery, you'll find everything you need, including tutorials, on the jQuery website. And to make the call periodically, just search google for "javascript setInterval".
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 05-07-2012, 08:10 AM Re: How to make page title, auto refresh every x seconds (using javascript/jquery/oth
chrishirst's Avatar
Defies a Status

Posts: 43,949
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
And of course by doing that stand a very good chance of crashing the browser after about five or ten minutes.

To do what you want without running out of browser resources on the client, you need to be using JAVA applets and servlets.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-07-2012, 04:24 PM Re: How to make page title, auto refresh every x seconds (using javascript/jquery/oth
miki86's Avatar
Extreme Talker

Posts: 239
Location: print_r($serbia);
Trades: 0
Quote:
Originally Posted by chrishirst View Post
And of course by doing that stand a very good chance of crashing the browser after about five or ten minutes.
You mean after making ajax request on a 10 seconds period and changing page title?

Im asking because i have a page on which im running 3 periodical requests (5, 10 and 20 seconds) and im pulling some heavy data.
But fortunately i have a 5 minute timeout so i can save some resources, i didn't tried without it but i never had a crash so far.
I did some testing to simulate "heavy" server load, say 70 requests in 10 seconds (i can't click faster ), all of them finished loading in about 200-350ms.

btw here's how to do it with mootools (not tested):
PHP Code:
var pageTitle document.title;
var 
func_newPM = function() {
    var 
reqURL 'file1.php';
    var 
AjaxReq = new Request({
        
urlreqURL,
        
method'get',
        
onComplete: function(responseText) {
            
document.title "("+responseText+") - "+pageTitle;
        },
    });
    
AjaxReq.send();
}
tCheckPM func_newPM.periodical(10000); 

Last edited by miki86; 05-07-2012 at 04:35 PM..
miki86 is offline
Reply With Quote
View Public Profile
 
Old 05-07-2012, 05:18 PM Re: How to make page title, auto refresh every x seconds (using javascript/jquery/oth
chrishirst's Avatar
Defies a Status

Posts: 43,949
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
But fortunately i have a 5 minute timeout so i can save some resources, i didn't tried without it but i never had a crash so far.
Provide the "timeout" allows any resources to be released and/or reused.

It is not the request rate that can hog resources but the javascript objects that are created and in some instances cannot be reused, but never get released or destroyed, so each iteration creates new objects and eventually can/will run out of 'heap' space. It's mainly due to javascript being event driven.

Java on the other hand has much better 'garbage collection' processes that will release objects and memory when finished with.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-07-2012, 07:20 PM Re: How to make page title, auto refresh every x seconds (using javascript/jquery/oth
miki86's Avatar
Extreme Talker

Posts: 239
Location: print_r($serbia);
Trades: 0
Of corse, that's something im aware of.
If the objects keep piling up the browser will eventualy crash.
I mentioned multiple requests because, in my case, object creation depends on request rate.
If the user is inactive for 5 minutes all the requests stop and there is no more object creation.
If 10 objects need to be created i have a delay of 1s so i get a nice feed of data and enough time for browser to do it's thing and while the new objects are created, old ones are destroyed.

I believe java is better when you are operating with more information but changing page title for one page is not so demanding task so javascript can do it with no problems.
miki86 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to make page title, auto refresh every x seconds (using javascript/jquery/others)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.59981 seconds with 11 queries