Reputation: 26637
My page has a popup window that should enable searches:
The problem is that the popup is located at a scrolled down part of the page, and when reloading the page with the search results the popup is "open" but the entire page begins at the top again since it was a new hit. How do I make the page go directly "halfway" scrolled down so that the results view matches the window? Should I use some kind of anchor?
Upvotes: 1
Views: 106
Reputation: 26898
You have two choices here:
A) Use an anchor. Give an ID to the div
that has your searchbox (let's suppose it's searchdiv
), and then http://yoursite.com/page.html#searchdiv
would automatically scroll to searchdiv
. Here's a little demo to elaborate this: little link. (Notice the URL in your browser's location bar).
B) If you want to be a bit more fancy and animate the scroll, use jQuery
var tp = $("#searchdiv").offset().top; //get the element's top
$('html, body').animate({scrollTop: tp}, 500); //animate for 500ms
A little demo of this method: little link.
I hope that helped!
Upvotes: 3
Reputation: 2116
You can use the #tag
so it goes <a name="xyz"></a>
at the position to want to display
redirect to
index.php#xyz
Upvotes: 0