Find Center Right of screen using JQuery

Posted on 2009-05-04
Last Modified: 2012-05-06
Hi to all,

I have a Visual Studio 2008 ASP.Net application. This application is written in VB.Net. I use the JQuery Library for most of my JavaScript.

I am using the code below to display a div for pop up. As you can see the div pops up where the mouse is clicked. I want to display the pop up in the middle right of the page. How would I do that?

I am working of a sample below and am still learning JavaScript
$(function() {

            $(document).click(function(e) {

                //getting height and width of the message box

                var height = $('#popuup_div').height();

                var width = $('#popuup_div').width();

                //calculating offset for displaying popup message

                leftVal = e.pageX - (width / 2) + "px";

                topVal = e.pageY - (height / 2) + "px";

                //show the popup message and hide with fading effect

                $('#popuup_div').css({ left: leftVal, top: topVal }).show().fadeOut(1500);



Open in new window

Question by:ALawrence007
LVL 12

Accepted Solution

alien109 earned 500 total points
ID: 24296773

Author Closing Comment

ID: 31577598
Thank you sir. Easy and fast to implement.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sums of coloumns in html/java 15 64
iframe detection of parent window scale 20 59
Replace &lt; with < 14 53
Regular Expression 1-100 with two digits 15 21
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now