Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to force refreshing a popup window data launched with js onload?

Status
Not open for further replies.

elwinbox

Technical User
Oct 8, 2007
5
I use the javascript triggered popups in my PHP script for passing messages/instructions to the script user.
Unfortunately, some browsers (e.g.Opera) seem not to refresh the popup content when the onload event opens a popup window and the data displayed is not up-to-date, apparently it is re-read from he browser's cache memory. I don't want to use the META Refresh instruction for the purpose, cause it's an overkill for my needs and in the first place it doesn't refresh in the first moment the window shows up, but only AFTER the specified time interval, so it is useless to me; the other 'href' instruction would be great, if one could launch it without bothering the user to click on it.. - but how could I force a one-time refresh only - i.e. immediately after the onload event? Unfortunately, using the onload trigger with the "history.go(0)" instruction starts an endless loop - a vicious circle of reloading the content, which brings up-to-date content to the window, but abuses the server.
Is there really no way to automatically force a one-time refreshing of the content of the popup window without bothering the user to click on the hyperlink?

(this looks like: <A HREF="javascript:history.go(0)">Click to refresh the page</A>
(by Joe Burns)
 
You could try the old trick of adding a parameter to the URL of the source you're loading in the popup ("cache busting")... for example, instead of this:

Code:
window.open('[URL unfurl="true"]http://www.whatever.com/somefile.html',[/URL] '', '');

You would use this:

Code:
window.open('[URL unfurl="true"]http://www.whatever.com/somefile.html?cacheBuster='[/URL] + new Date().getTime(), '', '');

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks, Dan. Unfortunately, it doesn't work...
At least with the Opera En 9.24, (there's no such problem with Netscape 7, IE55 or SeaMonkey I checked);
I have altered the code from:
<BODY onload="wopen('komunikat.php', 'popup', 640, 140); return false;"></BODY>
to:
<BODY onload="window.open(' + new Date().getTime(), 'popup', 640, 140); return false;"></BODY>
but it hasn't improved anything.
I'm wondering if this shouldn't be done in conjunction with
altering the META tag content to sth like->
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
which is suggested at but I don't know how to update the timestamp there...
I tried also the other option from same site:
putting <meta http-equiv="no-cache">, but it doesn't work neither.
Looks like a trivial but nasty thing.
 
Hi, Dan! We've got it!
I have put the new META instruction in place and used
the javascript datetime function from your
code - it works now!! Every time as fresh as it gets!
:)

Thanks a lot for your hint:=)
 
Opera really is the pits when it comes to caching. I ran into a similar problem on a project I worded on about 6 months ago - no matter how many "no-cache" directives we had in place, and no matter what Opera's cache settings were, it alwasy gave you a cached version.

I can't understand why the guys at Opera can't sort it out - it's shocking for a modern browser to be so damn buggy (IE 6 aside!)

We ended up adding about 20 lines of JS purely to get around Opera issues. How crap is that?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top