Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.location screen bump

Status
Not open for further replies.

dragonturtle

Programmer
Sep 25, 2003
55
CA
Hi,

when I use window.location = URL to do a redirect, if I am at the bottom of a large page, upon running the redirect I am bumped to the top of the page before the redirection occurs. It's kind of jarring everytime it happens... is there a reason for this (happens on IE 5 and 6), and is there a way around it?

Thanks.

 
I am assuming you have something like the following:

<a href=&quot;#&quot; onClick=&quot;window.location=URL&quot;>foo</a>

when you specify '#' the browser is looking for an anchor and, since you didn't specify a name, it brings you to the top.

you could do the following:

<a href=&quot;javascript:window.location.href=URL&quot;>foo</a>
 
I didn't know about the anchor, thanks for that info. My implementation is different though; I have a function called from the onClick event on an input button. So, my page is something like this:

Code:
<script>
function goToPage(param)
{
  str=document.myform.myText.value;
  window.location=&quot;nextpage.asp?p=&quot;+param+&quot;&q=&quot;+str;
}
</script>

<form name=myform>
<input type=text name=myText></input>
<input type=button onClick=goToPage(1)>
</form>

Screen bump always happens when I click the button. Is it because I'm doing the redirection through a function?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top