Robert,
Thanks very much for the email with solution. Do you know how to pass
parameters to javascript function? Because when I open a new window,
Say myUrl.aspx, I need to pass querystring variables too,
Like "myUrl.aspx?param1=3Dvalue1¶m2=3Dvalue2" and the values are
dynamic
Any idea?
-----Original Message-----
From: Robert Nyman [mailto:robert.nyman@c...]
Sent: Thursday, December 12, 2002 4:56 AM
To: javascript
Subject: [javascript] SV: refresh parent page but go back to previous
section
Christine,
This code will do the trick for you:
var strFocusItem =3D null;
window.onload =3D function (){
strFocusItem =3D (location.href.search(/\?itemFocus=3D\w+/) !=3D -1)?
new
String(location.href.match(/\?itemFocus=3D\w+/)[0]).replace(/\?itemFocus
=3D/
g, "") : null; =09
if(strFocusItem){
document.getElementById(strFocusItem).focus();
}
}
function openWin(oElm){
strFocusItem =3D oElm.id;
window.open("yourURL.htm", "",
"top=3D200,left=3D200,width=3D200,height=3D200");
}
function reloadWithFocusItem(){
var strNewLocation =3D location.href;
if(location.href.search(/\?itemFocus=3D\w+/) !=3D -1){
strNewLocation =3D new
String(location.href.match(/\?itemFocus=3D\w+/)[0]).replace(/(\?itemFocu
s=3D
)\w+/g, ("$1" + strFocusItem));
}
else{
strNewLocation =3D location.href + "?itemFocus=3D" +
strFocusItem;
}=09
location.href =3D strNewLocation;
}
You need to give all your links an id. The HTML I used with this code
was this:
<a id=3D"linkOne" href=3D"#" onClick=3D"openWin(this); return
false">Open
test</a><br>
<table>
<tr>
<td height=3D"2000">A table cell</td>
</tr>
</table>
<a id=3D"linkTwo" href=3D"#" onClick=3D"openWin(this); return
false">Open
test</a>
And in the small window:
<a href=3D"#" onClick=3D"window.close();
window.opener.reloadWithFocusItem()">Close</a>
/Robert
-----Ursprungligt meddelande-----
Fr=E5n: Christine_Sun@c...
[mailto:Christine_Sun@c...]
Skickat: den 11 december 2002 23:34
Till: javascript
=C4mne: [javascript] refresh parent page but go back to previous
section
Hello, Friends,
I think I have posted the problem once before, but didn't get the exact
solution. I thought I give another try. I have a page which is quite
long. From various section of the page Links would pop up a new window
to do something. After the work is done In the child window, I refresh
the parent window and then close the child Window. The javascript
command I use to refresh the parent window is
Window.opener.location.reload();
However, after the refreshing, the parent window is at the very top of
The page instead of the previous section where the link was. Any idea
how I can make it refresh but stay at the proper location? If you
manually refresh the page, you can use F5. But how can I do it using
javascript? Many thanks ahead.
Christine Sun