Javascript window.location only works once!!

I have a store locator page.  Testing on IE8.   Clicking on a store name & address paragraph invokes a javascript funtion that diplays a google map.  The map display function sets up a listener function to display the name and address when the icon on the map is clicked.

The map displays at the end of the page.  I want the function to terminate by scrolling to the map.  Everything works great at first, the page loads, I click on a store name, and I'm scrolled to the map.  However, if I scroll back up to the store list and click on another store, the page doesn't scroll (doesn't move at all).  However, the new map has been displayed, and except for the lack of scrolling after the first time, everything works great.

code snippets:
function disp_map( lat, lng, balloon_text) }
...
    map.addoverlay(marker);  // this causes the map to display
    window.location = window.location + "#the_map";
}
<p class="store_block onclick="disp_map(34.011285,-118.400275,'balloon text goes here')">
   store name<br />
   address<br />
  phone<br />
</p>
//  more stores go here
<a name="the_map></a>
<div id="map"></div> // the map is displayed in this div
JoeToddAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
try changing this:

<a name="the_map></a>

to:
<a name="the_map" id='the_map' tabindex='-1'></a>

AND immediately after:
 window.location = window.location + "#the_map";

put:
document.getElementById('the_map').focus();

Open in new window

JoeToddAuthor Commented:
Thanks for your quick reply. It didn't work, but I paid more attention and noticed something interesting.
The url window at the top of my browser has the following:
After I display the map the first time:
http://localhost/lrw/store_locator.php#the_map

after the second time:
http://localhost/lrw/store_locator.php.#the_map#the_map
the concation continues to repeat as I click on more stores!  That explains why it doesn't scroll after the first time, but doesn't tell my (I'm a javascript novice) how to get it to work correctly.
Thanks,
Joe
hieloCommented:
OK, then instead of:
 window.location = window.location + "#the_map";

try:
 location.href = location.href.substring(0, location.href.indexOf("#") ) + "#the_map";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JoeToddAuthor Commented:
Perfect!!!!

Thanks,

Joe
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.