Foolproof method to refresh frames

Posted on 2002-04-29
Medium Priority
Last Modified: 2007-11-27
I am working on a site using frames (I know, they suck!), but I am having a problem with the refresh method used to change content.  Basically, I have three frames - "banner", "buttons" and "body".  The buttons frame is an ASP page that contains basic navigation available to anonymous users and additional navigation options if the user is logged in (through a session variable).  If they login successfull (through a script in the "body" frame), the ASP code sends the following JavaScript to the client (again in the "body" frame):

<!-- Begin    
window.top.location.href = "default.asp"
//  End -->

This refreshes the entire frameset and reloads the "buttons" frame which now knows the user is logged in and will display the additional buttons.  This works 99% of the time.  In fact, I can not duplicate the problem  on my machine (but I also have my browser set to never cache pages).  I am getting some reports that some users, from time to time, won't have the frameset refresh and they never see the addition "logged in" user buttons.  I am assuming that this is due to some sort of browser caching.  Does any one have a "stronger" method to use to force all the frames to reload?  Obviously, the user can just hit "refresh" to have the new frames load, but we are dealing with very unknowledgeable users.  I have added disclaimer text to the page to tell the users this, but it looks tacky.  I have tried the ASP Response.Redirect method, but again this only loads into the frame that the response object is called from (in this case, the "body" frame).  Any help is appreciated.
Question by:bmccleary

Expert Comment

ID: 6979034
Use this quick form for the logon & it'll automatically reload the frame.

<INPUT TYPE="button" value="enter" onClick="window.location.reload()">
LVL 19

Expert Comment

ID: 6980632
It's most likely a cache problem, and one you're not going to overcome by refreshing the window.

When you load the logged in page, load BOTH pages, not just one, and make sure that the buttons page has a different URL. YOu can do this by adding a querystring to it -- the querystring will be ignored, but the browser will see the URL as a new page and should force a reload.

Or create a new frameset, and load that. Frames do NOT refresh correctly, and in Netscape they often don't refresh AT ALL -- you have to go to a new URL to get the new content.

That would probably be the easiest route, if you're stuck with the frames. Personally, I'd do everything I could to redesign and get rid of the frames. They're going to cause lots of problems if you're using dynamic content.

Author Comment

ID: 6980730
Thanks for the info!

That method won't work because I need the page to post to itself and have the ASP code determine if the logon was successfull.  Only the ASP page can send the data to refresh the frameset if successfull.  Any other thoughts?

You are right, frames are a pain but I am not going to spend the time changing the format unless this client pays for it... so for now we are stuck with them.  The page actually does get refreshed to a frameset with a querystring ("default.asp?requestedpage=aboutus.asp") and like I say it works almost all the time.  Even for the users that see the problem, it only happens to them every so often.  It sounds like something is getting loaded too quickly or too slowly and the browser doesn't realize a change.  Should I use a timer function?

One other thought is that I can use the HTML Meta "refresh" Tag and set it to 0 seconds, but I don't know how to target the entire frameset (parent window) with this tag.  Do you know?
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.


Expert Comment

ID: 6981045
You can use a case statement to determine if the user is logged in or not, and display the page accordingly:

IF user authenticates
   SET variable


   --display this menu--
   --display this menu--


This loads both menus, and chooses one to display based on the variable when the page is refreshed.  If you want to keep the menu source code hidden, the be sure to put it inside the ASP code (response.write).  Let me know if you need more details.


Author Comment

ID: 6981638
That is exactly what I am using for the buttons frame.  The problem is that when the frameset is automatically refreshed from the JavaScript placed in the body frame once a user has successfully logged in, that the code in the buttons frame is either not reloaded because of caching or it somehow doesn't catch (because of the server variables perhaps?) that it needs to load the enhanced version (in your example - case 2).  Thanks though!
LVL 19

Expert Comment

ID: 6982004
I suspect it's not you -- it's their browser or settings. TRy the dummy querystring trick, it should force the browser to refresh the page regardless of their settings. You can also put a javascript in the buttons page to check whether the body page URL is the one that seems to be causing the problems, and have the buttons page reload if it is.

Netscape in particular is really bad with refreshing frame content... drives me nuts when I'm checking the few things I have in frames.

Accepted Solution

TenTonJim earned 200 total points
ID: 6982692
Try these...
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">
and try passing the variable to the frameset itself to determine which frame gets loaded...
<% If Request("adminner") <> "" Then %>

<frame name="theBody" src="youradminpage.asp" noresize scrolling="auto" marginwidth="0" marginheight="0">


<frame name="theBody" src="avg_joe_user.asp" noresize scrolling="auto" marginwidth="0" marginheight="0">

<%End If%>

LVL 23

Expert Comment

ID: 6988800

if the top window is default.asp, then this will work for you:


where true indicates that the data is to be explicitly retrieved from the server and not from cache.

Author Comment

ID: 6991718
Thanks for the info.  This is tough to troubleshoot, because as I said, I can't duplicate the error.  But, I tried you code and I haven't heard any complaints yet, so hopefully that fixed it.

Thanks to all who responded, your comments were all helpful.

I looks like you are hunting for my questions ; )
I will try your method if it turns out that people are still not seeing the refreshed screen.  Thanks, I do appreciate it!

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question