Click to See Complete Forum and Search --> : How do I have a page automatically refesh ONLY ONCE!


mysticonline
12-23-2003, 04:00 AM
I've searched high and low and am unable to find any scripts or instructions on how to have a page automatically refresh ONLY ONCE after initially being loaded/viewed (as per whatever time variable/delay is set). I've found forwarding scripts/jumpers (which is not what I need) and scripts that repeatedly reload the same page automatically, in a loop, after a delay (eg: for random banner display). That doesn't work for me either. All I want is for the SAME page to ONLY refresh ONCE (after a few seconds as per configurable time delay) after initially being loaded/viewed and then STOP! After that, I don't want it to automatically refresh again unless the surfer leaves and views another page, and then returns to view this page again. At that point, it should do another SINGLE automatic refresh. Only refresh ONCE upon entry (ALWAYS),... not upon exit or repeatedly during viewing. I don't want it to be stuck in a perpetual "loop"! Is there any way to accomplish this? HELP!!!

AdamGundry
12-23-2003, 04:11 AM
This may do what you want:
<script type="text/javascript">
// Number of milliseconds to wait before reloading
refreshTime = 2000;

if (location.search != '?refreshed'){ setTimeout('location.search = "?refreshed"', refreshTime); }
</script>Adam

mysticonline
12-23-2003, 04:49 AM
Adam - Thanks a lot. the script works like a charm but, unfortunatley, didn't fix my problem. I donwloaded & am using the HV Menu from dynnamicdrive.com : http://www.dynamicdrive.com/dynamicindex1/hvmenu/index.htm and implemeted it on our webpage : http://www.mysticonline.com/demo2/index.htm The problem is that when the page is 1st loaded, the drop-down menu doesn't show up. But, if you manually refresh, it does. If you click on the "Design" or "Print" links in the top frame, you'll see what I mean. The resulting page is the only page with the refresh script you supllied embedded, but even after it automatically refreshed in 2 seconds, it still isn't showing the menu. You actually have wait for the entire page to load & then manually click refresh for it to show. Why is that? You can also try some of the other pages (which don't have the refresh script embedded) and see the same thing happen. Not all link are complete, but quite a few are in the Design/Print section. The web section does not utilize the menu, so don't expect it to appear. Since I wasn't able to circumvent the problem with your script, maybe you can suggest an actual fix! Thankx.

AdamGundry
12-23-2003, 07:30 AM
Interesting. Refreshing either the top frame or the bottom frame does not cause the menu to appear, you need to refresh the whole frameset to do so

I'm afraid I can't find anything immediately obvious wrong with your script, apart from possibly one section, this part of exmplmenu_var.js:

var FirstLineFrame='navig'; // Frame where first level appears
var SecLineFrame='space'; // Frame where sub levels appear
var DocTargetFrame='space'; // Frame where target documents appear

These lines appear to be referring to frames which do not exist; perhaps this could be your problem.

Alternatively, You might be able to rewrite the workaround like this, which hopefully will solve the problem:

<script type="text/javascript">
// Number of milliseconds to wait before reloading
refreshTime = 2000;

if (top.location.search != '?refreshed'){ setTimeout('top.location.search = "?refreshed"', refreshTime); }
</script>
Other than that, all I can suggest is contact the original author of the script. It is very complex, and it is possible there is a bug in the script itself.

Adam

mysticonline
12-23-2003, 03:06 PM
As you suggested, I contacted the developer, and this was their response: "When the script is used on a single page. (or on one frame) the frame variables FirstLineFrame, SecLineFrame and DocTargetFrame should be "". This falls right in line w/ what you had also mentioned about referring to frames which don't exist. I made this correction and everyhting seems to be working fine (for the moment). Thanks for all your help!

AdamGundry
12-26-2003, 04:51 AM
No problem. Happy Christmas. :)

Adam