Solved

HTML or Javascript Reload not Refresh

Posted on 2004-04-28
14
4,104 Views
Last Modified: 2007-12-19
Hi there,
             i have been trying to refresh an ASP page without having the page Reload and scroll back to the top. I have a framed application and have been using a

<script>
function ReloadTasks()
{
parent.menc.location.href="tasks.asp"
}
</script>

to reload a page in a different frame. I have tried the parent.menc.location.reload(true) option but it does not work.

What i am trying to do is not have the page scroll back to the top as the reload occurs.

Can you help?

Neil
0
Comment
Question by:nlegault
  • 7
  • 6
14 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 10943230
Only an idea:

<script>
function ReloadTasks(){
  sp = parent.menc.offsetTop;
  parent.menc.location.reload(true);
  parent.menc.scrollTo(0, sp);
}
</script>


0
 

Author Comment

by:nlegault
ID: 10943289
This script did not work. The effect was the same.... Do you have another idea???

Neil
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10943444
Sorry, that was not a tested idea.
Here a tested and working one:

<script>
function ReloadTasks(){
 sp = parent.menc.document.body.scrollTop;
 parent.menc.location.reload(true);
 setTimeout("parent.menc.scrollTo(0, "+sp+")", 100);
}
</script>


Increase the delay time if 100 miliseconds are to not enough.

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10943465
Why don'y you try a named Anchor...

<script>
function ReloadTasks()
{
parent.menc.location.href="tasks.asp#here"
}
</script>


In your HTML just above or around where you want the top of the page to be...

<a name="here"></a>
0
 

Author Comment

by:nlegault
ID: 10943518
Hi Zvonko,
               funny behaviour....in my HTA app it does not work and in the web browser it brings me back to the top.... i really need it to only refersh and not scroll to top but stay exactly where it is...

Neil
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10943552
In HTA you have to add to every <frame> definition this attribute:
<frame name=menc src=menc.htm APPLICATION=YES>
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10943564
And it was working for me in IE and as HTA.
If you have problems, then you have typos :)
0
 

Author Comment

by:nlegault
ID: 10950343
Hi Zvonko,

Still not working...I have in my frames page:
<frameset rows="25,*" cols="*" frameborder="yes" border="0" framespacing="0">
  <frame src="support/topc.htm" name="topc" scrolling="no" noresize >
  <frameset rows="*" cols="384,*" framespacing="0" frameborder="NO" border="0">
  <frameset rows="540,150" cols="1" frameborder="no">
    <frame src="support/tasks.asp" name="menc" scrolling="yes" APPLICATION=YES>
      <frame src="projc.htm" name="projc" scrolling="yes" APPLICATION=YES></frameset>
    <frame src="support/conc.htm" name="conc" scrolling="yes" APPLICATION=YES>
  </frameset>
</frameset>
<noframes>

In my content "conc" frame i have a details.asp page that has:

<script>
function ReloadTasks(){
 sp = parent.menc.document.body.scrollTop;
 parent.menc.location.reload(true);
 setTimeout("parent.menc.scrollTo(0, "+sp+")", 100);
}
</script>


AND:

<body onload="ReloadTasks()" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" class="DetailsPage">

I get the reload fine but it goes to the top of the page...It's very curious....I have tested with plain html the scenario and it works just like you said....But it does not work in my app...

Do you have any ideas?

Neil
0
 

Author Comment

by:nlegault
ID: 10950580
Zvonko,
            could it be that it's because i am using ASP and a database that it does not work....?

Neil
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10952243
No, it is because you are reloading the complette frameset.
To verify that frame menc is reset to zero position before frame conc can do the reposition, do this test:
Refresh only the rigth frame, the frame conc, by clicking the right mouse button over that frame and selecting refresh for that frame.
You will see that the left upper frame is not repositioned even when reloaded.

Do that test please.

0
 

Author Comment

by:nlegault
ID: 10952657
I have set-up 3 examples with the code. http://learning.intermaptechnologies.com/111/index.htm 
2 of them work fine but the one that uses the DB with ASP does not work....I hope it's a typo on my part! i really would like the conc to refresh without the user loosing his place in the menu.

Neil
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 10952936
I can not open that upper link.
But never mind, I have a new idea for you.

You need no ReloadTasks() function to manage the frame menc window scroll position.
The frame menc has to manage its window position itself.
Like this:
<html>
<head>
<script>
function storePos(){
  document.cookie = "win_"+window.name+"="+document.body.scrollTop;
}
function lastPos(){
  cVal = document.cookie.split("win_"+window.name+"=");
  if(cVal.length==2){
    window.scrollTo(0,parseInt(cVal[1]));
  }
}
</script>
</head>
<body onLoad="lastPos()" onScroll="storePos()">

0
 

Author Comment

by:nlegault
ID: 10987515
Hi Zvonko,
                sorry for the wait....Phenomenal !!!!!!!! Great !!!!    This is awesome now...I still have the other script refreshing the page and it works great!

Thanks,

Neil
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10991321
Oh! You are welcome :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding Row and Cell on a table 14 25
Asp in script 6 38
asp Google Map 2 32
2 separate CSS animations 2 17
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 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