【问题标题】:How to open a url as a bootstrap modal window?如何打开一个 url 作为引导模式窗口?
【发布时间】:2015-04-08 13:45:42
【问题描述】:

我有这行 PHP:


$STRING .= $b_f.'<a href="'.get_home_url().'/wp-login.php" class="ua5 '.$linkclass.'">'.$CORE->_e(array('head','5','flag_link')).'</a>'.$b_a;

此网址现在作为新网页打开。我怎样才能将它作为对话框/模态窗口打开?在我的代码中,我安装了引导程序。

【问题讨论】:

  • 试试这个解决方案jsfiddle.net/XUnj8/1它对我有帮助。
  • Vic Abreu,它不会打开模态框,通过单击按钮只会使网页右滚动条消失。有什么建议吗?
  • 不是真正的 Yaniv Noodelman,这是一个对我有用的工作示例,它已经在 J​​SFiddle 上工作。
  • 谢谢 Vic Abreu,会再试一次

标签: php wordpress twitter-bootstrap modal-dialog


【解决方案1】:

试试这个“技巧”:

<a href="http://twitter.github.io/bootstrap/" class="btn bootpopup" title="This is title" target="popupModal2">Open modal</a>

<div id="popupModal2" class="modal hide fade" tabindex="-1" role="dialog">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
            <h3>Title</h3>
    </div>
    <div class="modal-body">
      <iframe src="" style="zoom:0.60" frameborder="0" height="250" width="99.6%"></iframe>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal">OK</button>
    </div>
</div>

和js:

$('.bootpopup').click(function(){
  var frametarget = $(this).attr('href');
  var targetmodal = $(this).attr('target');
  if (targetmodal == undefined) {
    targetmodal = '#popupModal';
  } else { 
    targetmodal = '#'+targetmodal;
  }
  if ($(this).attr('title') != undefined) {
    $(targetmodal+ ' .modal-header h3').html($(this).attr('title'));
    $(targetmodal+' .modal-header').show();
  } else {
     $(targetmodal+' .modal-header h3').html('');
    $(targetmodal+' .modal-header').hide();
  }  
    $(targetmodal).on('show', function () {
        $('iframe').attr("src", frametarget );   
    });
    $(targetmodal).modal({show:true});
  return false;

});

只需将您的链接传递给按钮的href

DEMO

【讨论】:

  • @YanivNoodelman 这是一个令人震惊的例子。检查我的答案编辑 - 有一个演示链接。
  • 谢谢 Slim,我会这样做的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-08
  • 2014-08-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多