duanqin2026 2015-04-08 13:45
浏览 94
已采纳

如何打开一个url作为bootstrap模态窗口?

I have this line of 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;

This url opens now as a new webpage. How can i open it as a dialog/modal window instead? In my code i have bootstrap installed.

  • 写回答

1条回答 默认 最新

  • drzdu44226 2015-04-08 14:12
    关注

    Try this "trick":

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

    and the 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;
    
    });
    

    Just pass your link to the button's href.

    DEMO

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号