Refresh browser window on focus - is this possible?

J

jeff

Hello,

I'm building an internal web application using HTML/PHP/Javascript.
The system is flexible to the point where the user can have as many
browser windows open for each part of the system.

I would like a browser window that has just gained the focus to
refresh. Is this possible and how?

Thanks,
Jeff
 
L

Lasse Reichstein Nielsen

I'm building an internal web application using HTML/PHP/Javascript. ....
I would like a browser window that has just gained the focus to
refresh. Is this possible and how?

It depends on the browser. If it is an internal application, you might
know which browser is being used.

In Mozilla FB 0.7, IE6 and Opera 7 (probably other versions too), you
can use:
window.onfocus = function() { /* do someting */ };

/L
 
E

e

I'm totally making this up, but what about:

<script>
function refreshMe()
{
window.location = window.location;
}
</script>
....
<BODY onFocus="refreshMe()">
....

I dunno if "window.location = window.location" will really force a new
server request of the page. refreshMe() might need to be written using this
trick:

var now;
now = new Date();
window.location = window.location + '?' + now.getTime();

This technique of appending the current time as a parameter to a resource
name works with images; it prevents the browser from using a cached copy of
the image (webcams use this trick to force the browser to grab the same
image file from the server over and over without using the cached version),
but I have NO idea if it works with window.location :p
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,797
Messages
2,569,646
Members
45,374
Latest member
VernitaBer

Latest Threads

Top