Avatar of dotnetcoderpro
dotnetcoderpro
Flag 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
ASP.NETCSSJavaScript

Avatar of undefined
Last Comment
dotnetcoderpro

8/22/2022 - Mon
disrupt

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
disrupt

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...
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
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");
nishant joshi

sry,
$("#div1").scrollTo("ele");
jagrut_patel

Try this:

$("#PopUpOverlay").dialog("option", "position", "center");
$("#PopUpOverlay").dialog('open');
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
dotnetcoderpro

ASKER

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
disrupt

ASKER CERTIFIED SOLUTION
disrupt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jagrut_patel

Yes, that is how it worked for me.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
dotnetcoderpro

ASKER
This problem is solved..thanks so much.