. . .

iFrame in jQuery UI Dialog

Published: November 28, 2010

On This Page

    To display iFrame in jQuery UI Dialog, use the following code.
    
    <html>
    <head>
        <link rel="stylesheet" href="./styles/smoothness/jquery-ui-1.7.2.custom.css" type="text/css" media="screen" />
        <script type="text/javascript" src="./scripts/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="./scripts/jquery-ui-1.7.2.custom.min.js"></script>
        <script type="text/javascript">
        $(function() {
            $('a').click(function(e) {
                e.preventDefault();
                var $this = $(this);
                var horizontalPadding = 30;
                var verticalPadding = 30;
                $('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
                    title: ($this.attr('title')) ? $this.attr('title') : 'External Site',
                    autoOpen: true,
                    width: 800,
                    height: 500,
                    modal: true,
                    resizable: true,
                    autoResize: true,
                    overlay: {
                        opacity: 0.5,
                        background: "black"
                    }
                }).width(800 - horizontalPadding).height(500 - verticalPadding);
            });
        });
        </script>
    </head>
    <body>
        <ul>
            <li><a href="http://www.google.com" title="Google Dialog">Google</a></li>
            <li><a href="http://jquery.com" title="jQuery Dialog">jQuery</a></li>
            <li><a href="http://jqueryui.com" title="jQuery UI Dialog">jQuery UI</a></li>
        </ul>
    </body>
    </html>

     

    Check out the online demo of the above code and/or download the files yourself if you want.

    Source: http://elijahmanor.com/webdevdotnet/post/jQuery-UI-Dialog-w-Resizable-iFrame.aspx

    Don't forget to share this post

      Let's Build Digital Excellence Together


      • Cost Efficient Solutions.
      • Minimal Timelines.
      • Effective Communication.
      • High Quality Standards.
      • Lifetime Support.
      • Transparent Execution.
      • 24/7 Availability.
      • Scalable Teams.

      Join Our 200+ Happy Clients Across Globe


      Free Consultation.

        Do you need tech help of your startup/business? Experts from our team will get in touch with you.

        Please do not post jobs/internships inquiries here.