I am looking for a plugin for opening modal windows on jquery. The plugin should be able to open a link in the modal window that the hapless user clicked on (it’s the link, not the hidden div, that overwriting the alert and notice is also not needed). This is implemented in the FancyBox gallery and works very well. I would like the same thing, but without the gallery, it was too healthy for such a nano-task.

Upnem question :)

    4 answers 4

    $('a.modal').live('click', function(){ $('body').append('<iframe src="'+this.href+'"></iframe>'); }); 

    The rest is a matter of stylization.

      maybe GreyBox will do ?

      • No, alas, it only works with layers. - Sharp - eyed
      • And what if there is an iframe in this layer of yours? - oleg42
      • The layer should not be used. There should be a link of the form: <a href="somepage.php?some-param=1" rel="modal-window"> Pysch </a> There are a lot of such references if there is not an Orthodox for each layer of the ifram . - Sharp - eyed

      I will add a little:

       <a href="/item/1" class="modal">Link 1</a> <a href="/item/2" class="modal">Link 2</a> <script type="text/javascript"> $('a.modal').live(function(e) { /* * Без preventDefault() будет переход по ссылке * Еще можно задавать <a href="#" data-url="/url"> */ e.preventDefault(); $('#popup>iframe').attr('src', $(this).attr('href')); $('#popup').gbxShow(); // GreyBox или jQueryUI.dialog или еще что }); </script> <div id="popup" style="display:none"> <iframe/> </div> 

        but in the jquery.1.9 version, live must be replaced with ON