Solved

HTML or Javascript Reload not Refresh

Posted on 2004-04-28
14
4,100 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
Comment Utility
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
Comment Utility
This script did not work. The effect was the same.... Do you have another idea???

Neil
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
And it was working for me in IE and as HTA.
If you have problems, then you have typos :)
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:nlegault
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Oh! You are welcome :)
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

Suggested Solutions

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

763 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

11 Experts available now in Live!

Get 1:1 Help Now