JavaScript doesn\'t allow you to update window.location without triggering a reload. While I agree with this policy in principle (it shouldn\'t be possible to
window.location
You can add an anchor to the URL without reloading the page and pick that up with javascript:
location.href = '.../#' + imageId;