2015-04-08 42 views
0

我此行的PHP:如何打開一個URL作爲引導模態窗口?


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

該網址會立即打開一個新的網頁。我怎樣才能打開它作爲對話框/模式窗口呢?在我的代碼中,我安裝了引導程序。

+0

嘗試這種解決方案http://jsfiddle.net/XUnj8/1/它幫助我。 –

+0

Vic Abreu,它不會打開模式,只需點擊該按鈕即可讓網頁右滾動條消失。有什麼建議麼? – Yanivn78

+0

不是真的Yaniv Noodelman,這是一個爲我工作的工作示例,它已經在JSFiddle上工作。 –

回答

2

試試這個 「絕招」:

<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

+0

對不起Slim,它只會打開新標籤中的鏈接... – Yanivn78

+0

@YanivNoodelman這是一個令人驚訝的例子。檢查我的答案編輯 - 有一個演示鏈接。 – Slim

+0

謝謝Slim,我會這樣做的 – Yanivn78

相關問題