Foolproof method to refresh frames

Posted on 2002-04-29
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 = "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?
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.


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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

776 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