2008-10-16 78 views
6

我一直在寻找jQUery thickbox显示与图像模态对话框,这是伟大的。但是现在我需要以类似的方式显示包含iFrame的隐藏的内容,并提供打开内容的链接。所以我会有这样的事情。jQuery Thickbox或类似的显示iFrame?

<a href="">Open window in Modal Dialog</a> 

<div id="myContent"> 
    <h1>Look at me!</h1> 
    <iframe src="http://www.google.com" /> 
</div> 

并且需要在对话框中显示它。可能吗?

回答

2

我使用jqModal,它工作得很好,而且很轻巧。这是我如何得到它与一个iFrame

这是HTML

<div class="jqmWindow" id="modalDialog"> 
    <iframe frameborder="0" id="jqmContent" src=""> 
    </iframe> 
</div> 

而且调用代码

function showModal(url, height, width) 
{  
    var dialog = $('#modalDialog') 
     .jqm({ 
      onShow: function(h) { 
       var $modal = $(h.w);     
       var $modalContent = $("iframe", $modal); 
       $modalContent.html('').attr('src', url); 
       if (height > 0) $modal.height(height);  
       if (width > 0) $modal.width(width);     
       h.w.show();   
      } 
     }).jqmShow();   
} 

function closeModal(postback) 
{ 
    $('#modalDialog').jqmHide(); 
} 
0

我有一个扩展jQueryUI的的对话框,使用iframe,因为它的基本工作查看...它调整了一些默认值(如添加一个确定/取消按钮),但应该是你需要的一个体面的基础。我知道这是一个古老的问题,但只是想让人们意识到这一点。

http://plugins.jquery.com/project/jquery-framedialog

+0

我试过这个插件,它隐藏了x-scrollbar。你能解决这个问题吗? - [查看我的回答] – 2010-07-22 14:36:38

0

下面是我的修补程序的详细信息。希望您可以将这些更改集成到您的JQuery插件中。我正在使用jQuery 1.4.2和jQuery UI 1.8.2。

jQuery中-frameddialog.js,我改变宽度和高度为100%(未PX),然后改变为FIX 1.7 jQueryUI的是代替以下:

wrap.bind('dragstart', function() { overlay.show(); }) 
    .bind('dragstop', function() { overlay.hide(); }) 
    .bind('resizestart', function() { overlay.show(); }) 
    .bind('resizestop', function() { overlay.hide(); });