Solved

HTML or Javascript Reload not Refresh

Posted on 2004-04-28
14
4,101 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

895 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

14 Experts available now in Live!

Get 1:1 Help Now