0

I saw a few questions asking how to stop page scrolling on opening a dialog. But I need my long page to scroll up/down to show a dialog.

On page load, if some condition met, I open a dialog:

   $(function () {
       if (someCondition) {
           $('#showOnce').dialog(); // default position seems to be center
       }
   });

If I close the dialog and scroll down to bottom of the long page and refresh, it open up the dialog but it keeps to show the bottom so, to see the dialog, I need to scroll up.

How can I make the page scroll up to show a dialog?

[Edit1] I noticed differences across browsers on page refresh:
- Chrome/IE keep scroll position but open dialog at top (so dialog not shown)
- FF keeps scroll position and open dialog at current position (I like this!)

bob
  • 2,674
  • 1
  • 29
  • 46
  • what's the condition you wanna do? – Chanckjh Jun 24 '13 at 05:50
  • i think question is alreay in stack. [http://stackoverflow.com/questions/1467102/dialog-box-not-positions-center-screen][1] [1]: http://stackoverflow.com/questions/1467102/dialog-box-not-positions-center-screen – Manish Parmar Jun 24 '13 at 05:55

2 Answers2

0

Does this help you? from jQuery API :

.scrollTop()

.scroll()

AntouanK
  • 4,880
  • 1
  • 21
  • 26
0

Try this,

$(function () {
   if (someCondition) {
       $('#showOnce').dialog(); // default position seems to be center
       $(window).scrollTop(0);
   }
});

on closing the dialog you can use,

$(window).scrollTo( '100%' );
Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106