如何使用jquery在mvc中显示屏幕中心的弹出窗口 [英] How to display popup in center of the screen in mvc using jquery

查看:99
本文介绍了如何使用jquery在mvc中显示屏幕中心的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看



我需要在屏幕中心显示弹出窗口。这段代码无法帮我显示在确切的中心。



View

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

<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>










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;
    }





已添加代码块

推荐答案

#ApplyTarget)。contents()。find( #ApplyStatus)。length> 0 ){
var res =
("#ApplyTarget").contents().find("#ApplyStatus").length > 0) { var res =


#ApplyTarget)。contents()。find( #ApplyStatus)。html();
("#ApplyTarget").contents().find("#ApplyStatus").html();


#ApplyHead)。html( 消息);
("#ApplyHead").html("Message");


这篇关于如何使用jquery在mvc中显示屏幕中心的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆