0

我正在使用引导程序 - 我怎样才能让它自动打开?如果 if 语句为真,我可以让它自动加载,而不是让 href="#Register" 启动?谢谢。

<?php 
      require 'header.php';
      require 'center.php'; 
      require 'footer.php';

        if(!isset($_SESSION['pay_address'])) {

            ?>
             <li><a data-toggle="modal" href="#Register">Register</a></li>
            <!--- Register Modal -->
<div class="modal fade" id="Register" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">Deposit Funds</h4>
        </div>
        <div class="modal-body">
         <p>Your unique deposit address for GigaDice is: <strong>1HXtoMuv6xU1rLGfn6C9z9H6REHEtAs1gW</strong></p>
          <p> If you have cookies disabled or clear them regularly, be sure to save your account ID and password.
              </p>
              <p>Alternatively, pay with Coinbase.  Coinbase allows for instant deposits!</p>
        <a class="coinbase-button" data-code="08409eb5d732affc131087bd72c48724" data-button-style="custom_small" href="https://coinbase.com/checkouts/08409eb5d732affc131087bd72c48724">Pay With Bitcoin</a><script src="https://coinbase.com/assets/button.js" type="text/javascript"></script>
        <p>Alternatively, pay with Inputs.io.  Inputs.io allows for instant deposits!</p>
        <script src='https://inputs.io/js/buttons.js'></script>
<a href='https://inputs.io/pay?to=Loker' class='inputsio' data-success='You may need to refresh the page.' data-to='Loker' >Fund Account</a>
                <br /><br /><p>If your deposit does not go through, e-mail deposits@gigadice.com.</p>
                            <p>Remember to click your balance to see if it has updated!</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div>
<!--- End Register Modal -->
            <?php

        }
?>
4

2 回答 2

0

在模态代码之后,您可以添加以下内容:

<script type="text/javascript">
    $(function(){
        //instantiate your content as modal
        $('#Register').modal({
            //modal options here, like keyboard: false for e.g.
        });

        //show the modal when dom is ready
        $('#Register').modal('show');
    });
</script>

DOM 准备好后将打开模式。放在 php 里面,if所以它只在模态 html 显示时显示。

更多信息请访问: http: //getbootstrap.com/javascript/#modals

于 2013-09-05T20:55:21.990 回答
0

如果您添加data-show=true到标记,它应该直接启动它。

于 2013-09-05T20:57:23.717 回答