Question

I am loading a jQuery UI window a few scrolls down from the top of the page. When it opens the Browser resets it's position to the top of the page.

If it helps just prior to the dialog loading I am inserting some HTML into the page (html for the dialog).

Does anyone know how to stop this?

Edit The answer on the question guessed what my problem was and solved it. Was invoking the link using the hash tag.

Was it helpful?

Solution

If you're invoking this via the <a href='#'> tag, be sure to preventDefault on the event. Otherwise it will return you to the top of the page onClick.

$("a.myWindow").click(function(event){
  event.preventDefault();
  /* Show dialog */
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top