Solved

Foolproof method to refresh frames

Posted on 2002-04-29
9
1,201 Views
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.
0
Comment
Question by:bmccleary
9 Comments
 
LVL 4

Expert Comment

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

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

Expert Comment

by:webwoman
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.
0
 

Author Comment

by:bmccleary
ID: 6980730
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?
0
 
LVL 1

Expert Comment

by:jello
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

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
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:bmccleary
ID: 6981638
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!
0
 
LVL 19

Expert Comment

by:webwoman
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.
0
 
LVL 2

Accepted Solution

by:
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">

<%Else%>

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

<%End If%>
-------------------------------------------

JimS.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6988800
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.
0
 

Author Comment

by:bmccleary
ID: 6991718
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!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now