On this map:
http://web.pacific.edu/documents/marketing/campus-map/version%202/stockton-campus-2.0.htm
I have an anchor at the top, and I want the page to jump to the anchor when a link is clicked.
I'm currently using
window.location = '#top';
It works as expected in FF, Opera, and Chrome, but not in IE 7.
I've tried all permutations like window.location.hash and window.location.assign() and also scrollIntoView(true) and focus().
How can I make it work in IE?
Edit: Nothing seems to work, which makes me think it's not the syntax, but something about the JS... here is the click event handler... could it be because it returns false? I'm grasping at straws.
// Click handler for each location link
$('#index a').click(function()
{
hideMarkers();
location.href = location.href + "#top";
var marker = showMarker( $(this).attr('data-id') );
GEvent.trigger( marker, "click" );
return false;
});
Edit: Assignment to window.location.hash breaks in IE7 and IE8 on pages that were loaded as a result of page redirection via the HTTP "Location" header. The solution is to return a page with Javascript that itself will perform the redirection. See the answer by Joe Lapp.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…