Jquery 打开页面时打开弹出框

Jquery 打开页面时打开弹出框,jquery,ajax,Jquery,Ajax,我有如下代码: $("document").ready(function (){ $(".open_popup").colorbox({width:"580px", inline:true, href:"#subscribe_popup"}); }); 这是弹出框,我需要打开页面时打开这个弹出框,打开这个弹出框我用这个代码 <a href="#" class="open_popup">Click here to open the popup</a>

我有如下代码:

    $("document").ready(function (){ 

$(".open_popup").colorbox({width:"580px", inline:true, href:"#subscribe_popup"});

     });
这是弹出框,我需要打开页面时打开这个弹出框,打开这个弹出框我用这个代码

<a href="#" class="open_popup">Click here to open the popup</a>


如何打开body上的弹出式onload标签。

一种方法是简单地触发链接上的click事件

$(window).load(function(){
    $(".open_popup").trigger("click");
});

如果您试图加载内联内容(
#订阅_弹出窗口
),则应使用
html
属性,而不是
href

发件人:

正如另一个答案所建议的,在
$(window.load()

尝试:

在Body标签上:

<body onload="javascript: pop()">


$(窗口)。加载(函数()
{
$('myModal').modal('show');
});
.popupp h4{
字号:1.6em;
颜色:#0084C4;
字体系列:“泰晤士报新罗马”,泰晤士报,衬线;
字体大小:粗体;
填充:0em 0em 0.5em 0em;
文本对齐:居中;
边际:0px;
}
.popupp h4 span{
字体大小:1.2em!重要;
}
.queryform输入[type=text],文本区域,输入[type=email],输入[type=number]{边框:1px实心#CEC7C7;边距底部:1em;轮廓颜色:FF5B36;宽度:100%;字体大小:0.9em;填充:1em;-webkit外观:无;颜色:#B1B1;}
.queryform输入[type=submit]{边框:1px实心#CEC7C7;页边距底部:1em;轮廓颜色:FF5B36;宽度:100%;字体大小:1em;背景:1000;填充:1em;-webkit外观:无;颜色:#fff;}
.queryform文本区域{高度:100px;}
.查询表格
{ 
填充:0.5em 5em;
}
.结束{
字号:4em;
}
.模式标题。关闭{
利润上限:-31px;
}
&时代;
需要即时服务吗???




接近
无论用户交互如何,当页面加载时,或者当单击
标记时,您是否希望出现弹出窗口?当我单击a时,它是打开的,但当加载页面时我需要打开是的,但当我正确理解您的意思时,弹出窗口的处理程序位于a的单击事件上。因此,当您模拟单击a时,弹出窗口将打开。此代码正在工作??而此代码可能会回答问题,提供有关如何和/或为什么解决问题的附加上下文将提高答案的长期价值。附加上下文仅用于易于理解的解决方案
$(window).load(function(){
    $.colorbox({html:$('#subscribe_popup')})
});
function pop()
{
    $("document").ready(function (){ 

       // load the overlay

        if (document.cookie.indexOf('visited=true') == -1) {
            var fifteenDays = 0;
            var expires = new Date((new Date()).valueOf() + fifteenDays);
            document.cookie = "visited=true;expires=" + expires.toUTCString();
            $.colorbox({width:"580px", inline:true, href:"#subscribe_popup"});
        }

        $(".open_popup").colorbox({width:"580px", inline:true, href:"#subscribe_popup"});

 });
}
<body onload="javascript: pop()">
        <!--Jquery bootstrap Library-->
    <!--bootstrap  css file-->
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">

        <!--Window Control Code (You Are Perform)-->
        <script>
            $(window).load(function()
            {
                $('#myModal').modal('show');
            });
        </script>
        <!--Window Control Code (You Are Perform)-->
        <!--Pop Style CSS-->
        <style>
        .popupp h4{ 
        font-size:1.6em; 
        color:#0084C4; 
        font-family:"Times New Roman", Times, serif; 
        font-weight:bold; 
        padding:0em 0em 0.5em 0em; 
        text-align:center; 
        margin:0px;
        }
        .popupp h4 span{ 
        font-size:1.2em !important;
        }
        .queryform input[type=text],textarea,input[type=email],input[type=number]{border: 1px solid #CEC7C7; margin-bottom:1em; outline-color: #FF5B36; width:100%; font-size: 0.9em; padding:1em; -webkit-appearance: none; color: #B1B1B1;}
        .queryform input[type=submit]{border: 1px solid #CEC7C7; margin-bottom:1em; outline-color: #FF5B36; width:100%; font-size:1em; background:#000; padding:1em; -webkit-appearance: none; color: #fff;}
            .queryform textarea{ height:100px;}
            .queryform 
            { 
                padding: 0.5em 5em;
            }

            .close {
            font-size:4em;
            }
            .modal-header .close {
                margin-top: -31px;
            }
        </style>
        <!--Pop Style CSS-->
        <!--Define Pop Up-->
          <!-- Modal -->
          <div class="modal fade" id="myModal" role="dialog">
            <div class="modal-dialog">    
              <!-- Define Pop Up content-->
              <div class="modal-content">
                <div class="modal-header popupp">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                  <h4 class="modal-title"><span> Need Instant Services </span> ??? </h4>
                  <div class="queryform">
                    <form method="post" action="contact-post.php">
                        <input type="text" name="name" placeholder="Enter Your Name" required> 
                        <br />                  
                        <input type="number" name="mobile" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" maxlength = "10" minlength = "10" placeholder="Enter Your Mobile Number" required>
                        <br />                  
                        <input type="email" name="email" placeholder="Enter Your Email Address" required>
                        <br />
                        <textarea name="msg" placeholder="Enter Your Requirment" required></textarea>
                        <br />      
                        <p align="center"><input type="submit" value="Enquiry" name="enquiry_home"></p>
                    </form>
                  </div>
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
              </div>      
            </div>
          </div>