Find Center Right of screen using JQuery

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

Who is Participating?
ALawrence007Author Commented:
Thank you sir. Easy and fast to implement.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.