JQuery: Can I use a dialog box to open an external web page?

Can I use jQuery Dialog to open an external web page, and if so, how?

Essentially, I want to replicate the capabilities of LightWindow using jQuery (LightWindow is script-based).

www.stickmanlabs.com/lightwindow/index.html

Ideally, I want to use something other than the core jQuery. If it should be a JQuery plugin, that’s fine, but I would really like it to be separated from the main functionality of such functions.

+5
source share
2 answers

In JQueryUI, you use the DIV as a dialog.

$(function() {
  $("#dialog").dialog();
});

, iframe DIV:

<div id="dialog" title="Google">
    <IFRAME style="border: 0px;" SRC="http://www.google.com" width="100%" height = "100%" >
</div>

Edit:

, LINK JQueryUI, :

JavaScript

$("a").click(function(event){
  event.preventDefault();
  $("#frame").attr("src", $(this).attr("href"));
  $('#dialog').dialog('open');
});

HTML:

<div id="dialog" title="Dialog Title">
    <IFRAME id="frame" style="border: 0px;" SRC="" width="100%" height = "100%" >
</div>
+9

JCasso, JavaScript:

$("a").click(function (event) {
    event.preventDefault();
    var page = $(this).attr("href");
    var title = $(this).text();
    $('<div></div>')
        .html('<iframe style="border: 0px; " src="' + page +
              '" width="100%" height="100%"></iframe>')
        .dialog({
            autoOpen: true,
            modal: true,
            height: 800,
            width: 400,
            title: title
    });
});

iframe dialog.

jsFiddle

0

All Articles