How do you open a URL in a dialog box JQUERY UI

前端 未结 4 1466
情书的邮戳
情书的邮戳 2020-12-17 00:52

I\'ve been looking for a simple solution for quite some time. I want a page (for example http://www.google.com) to be displayed in a JQuery UI Dialog window. The plan is to

4条回答
  •  清酒与你
    2020-12-17 01:03

    You may try this

    $(function(){
        $('a').on('click', function(e){
            e.preventDefault();
            $('
    ', {'class':'myDlgClass', 'id':'link-'+($(this).index()+1)}) .load($(this).attr('href')).appendTo('body').dialog(); }); });

    Above code will create a new dialog on clicking on any link on your page and also add a class name myDlgClass and an unique id for each dialog like link-1, link-2 and so on, but remember that only page link will be loaded not external link because of same origin policy.

    Update :

    To use an external site link you can use an iframe, here is an example using iframe.

提交回复
热议问题