Link to home
Create AccountLog in
Avatar of dotnetcoderpro
dotnetcoderproFlag for United States of America

asked on

How to get the popup window to center of the screen even after scrolling to different positions vertically ?


How to get the popup window to center of the screen even after scrolling to different positions vertically ?

I have the popup window such as $("#PopUpOverlay") which i get on the click of a particular links and want to get this popup window to the center of the screen always...even after scrolling vertically up and down in the browser window by applying css styles to the the center of the browser screen window. Even after scrolling some and if user clicks the link again, then popup window should pop onto the center of that portion of the screen.

Please provide me some suitable and dynamic solutions, it could be css styles and jquery code.

Thanks
Avatar of dotnetcoderpro

ASKER

I wasn't looking for producing the popup window...but was looking for positioning the already created popup window of type "DIV" to the center of the screen with logic on the lines of scrollTop or scrollLeft etc, that means, on each click of the popup link, the popup window should center to the screen after scrolling the vertical scroll bar of the browser....I hope that will give an idea of what i am looking for.  Screenshots for the Expected Solutions attached for your reference....Thanks
popup-position-1.bmp
popup-position-2.bmp
Take a look at the third link I sent you:

http://stackoverflow.com/questions/210717/using-jquery-to-center-a-div-on-the-screen

you should be able to center the div that way...
Avatar of nishant joshi
it's a problem that you said is at first time load???
then for fix a posiion to any element use...

use scrollto property of jquery

means you if your div id="div1" and want to show at an element which has id="ele" then


$("#div1").scrillTo("ele");
sry,
$("#div1").scrollTo("ele");
Try this:

$("#PopUpOverlay").dialog("option", "position", "center");
$("#PopUpOverlay").dialog('open');

Quick question, does this below code works even after we scroll on the browser vertically and click the popup link, then do we get the popup window to the center of the screen irrespective of wherever we are onto the browser scroll location :

$("#PopUpOverlay").dialog("option", "position", "center");
$("#PopUpOverlay").dialog('open');

Thanks
ASKER CERTIFIED SOLUTION
Avatar of disrupt
disrupt
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Yes, that is how it worked for me.
This problem is solved..thanks so much.