Link to home
Start Free TrialLog in
Avatar of bmccleary
bmccleary

asked on

Foolproof method to refresh frames

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.
Avatar of EricWestbo
EricWestbo

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

<FORM>
<INPUT TYPE="button" value="enter" onClick="window.location.reload()">
</FORM>
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.
Avatar of bmccleary

ASKER

Thanks for the info!

Eric,
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?

Webwoman,
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?
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

SELECT CASE VARIABLE

CASE 1
   --display this menu--
CASE 2
   --display this menu--

END SELECT


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.

-Elliott
Elliott,
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!
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.
ASKER CERTIFIED SOLUTION
Avatar of TenTonJim
TenTonJim

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Brian,

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

window.top.location.reload(true);

where true indicates that the data is to be explicitly retrieved from the server and not from cache.
TenTonJim,
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.

b1xml2,
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!