Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 24578
  • Last Modified:

Auto Refresh a WebPage

When you click refresh in the browser it refreshes the page and returns the screen view where you last had it. Is there a way to code this action so that I can auto refresh the page and return the viewer back to where they were in the page?
0
rcmb
Asked:
rcmb
  • 8
  • 5
1 Solution
 
seanpowellCommented:
When you say "auto refresh" do you mean every so often, or when clicking a button? How do you want the page to be refreshed?
0
 
rcmbAuthor Commented:
I would like the page to refresh every so often like every 2 minutes.
0
 
seanpowellCommented:
Well, the easiset way would be to add this to the <head> section of your page:

<meta http-equiv="refresh" content="120 ;url=index.html">
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
rcmbAuthor Commented:
I have tried that code and it refreshes the page but it always return me to the top of the page. I want the page to refresh and return to where the viewer was last viewing the page (say 3/4 down the page).
0
 
seanpowellCommented:
But you should know that this won't trap where the page was - you would need some complicated scripting to figure out where the position of the scrollbar is at the precise moment before the refresh...
0
 
seanpowellCommented:
Sorry - we got overlapped there. Read the above... can you explain why you're trying to do this - perhaps there's another way.
0
 
rcmbAuthor Commented:
Is there a way to assign a dynamic bookmark and then use

<meta http-equiv="refresh" content="120 ;url=index.html#bookmark">

as the code?
0
 
seanpowellCommented:
We can certainly appending the bookmark notation - but you still have the problem of knowing whether the user was viewing that dynamically created bookmark or not...
0
 
rcmbAuthor Commented:
I have an ASP page that displays the status of equipment/operations onboard US Navy Submarines. The different watchsections on the ship provide input as things change. When the Officer of the Deck views the master page I want the page to refresh every 2 minutes to gather any changes that may have been submitted. The problem is the page is very long and it the Officer of the Deck is reading Weapons Status and the page refreshes then he has to scroll all the way back down the page.
0
 
seanpowellCommented:
Yes, that's going to be a problem.

There are other options then. One would be to use separate iframe's on the page, and have the content in the iframe refresh, as opposed to the parent page. Is that an option for you?
0
 
seanpowellCommented:
For example:

<html>
<head>
</head>
<body>
<p>Equipment:<br />
<iframe height="200" width="600" src="equip.html" id="frame1" name="frame1" scrolling="no"></iframe></p>
<p>Operations:<br />
<iframe height="200" width="600" src="oper.html" id="frame2" name="frame2" scrolling="no"></iframe></p>
<p>Weapon Status:<br />
<iframe height="200" width="600" src="stat.html" id="frame3" name="frame3" scrolling="no"></iframe></p>
</html>

And each iframe page has <META http-equiv=refresh content=120> in the head section
0
 
rcmbAuthor Commented:
seanpowell,

I think you have a great idea there. Not only will that somewhat solve my problem but it will make management of the page much easier. I am going to build that page tomorrow and I will let you know how it worked.

RCMB
0
 
seanpowellCommented:
Thanks - I was just thinkng about the page management issue given your description of what type of information you're processing. I thought that if you could deal with separate components that can easily be included/deleted from various screens it might be quite helpful.

Let me know if you need any work done on the front end, it's what I do for a living ;-)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now