Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
View

I need popup in exacly center of the screen.This code not helping me to show in exact center.

HTML
<section class="msg-pop" id="ApplyMBox">
    <span class="msg-pop-head"><span class="msg-headtext"><h3 id="ApplyHead"></h3></span></span>
    <section class="share-pop-inr">
        <span class="clr"><label id="ApplyMsg"></label></span>
        <section class="ok-button">
            <input type="button" value="OK" class="butn-style-01 shr-btn-02" name="" id="Updatepopbtn">

            <span class="clr"></span>
        </section>
        <!-- stop: share privacy settings -->
        <span class="clr"></span>
    </section>
    <span class="clr"></span>
</section>



Java
function ApplyComplete() {
        if ($("#ApplyTarget").contents().find("#ApplyStatus").length > 0) {
            var res = $("#ApplyTarget").contents().find("#ApplyStatus").html();
            $("#ApplyHead").html("Message");
            $("#ApplyMsg").html(res);
            $("#ApplyMBox").show();
            $("#ApplyMBox").center();
            $("#ApplyBG").show();
        }
    }


 jQuery.fn.center = function () {
        this.css("position", "absolute");
        this.css("top", Math.max(0, (($(window).height() - $("#ApplyMBox").outerHeight()) / 2) +                                    $(window).scrollTop()) + "px");
        this.css("left", Math.max(0, (($(window).width() - $("#ApplyMBox").outerWidth()) / 2) +
                                                    $(window).scrollLeft()) + "px");

        return this;
    }


code block added
Posted
Updated 26-Nov-15 21:46pm
v2

1 solution

Try Below code:-


C#
You can just use another CSS style, try position: fixed
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900