Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Ajax and JavaScript

  • Print
  • + Share This
From the author of Using a Dialog Window as a Popup

Using a Dialog Window as a Popup

A jQuery Mobile dialog window can also be used as popup window. The main difference between a dialog window and a popup is that a dialog window typically requires some sort of feedback in the form of a button interaction, for example. A popup window can contain anything[md]for example, an image gallery, video, copy, and so on.

The following example shows how an image can be loaded in a popup window using jQuery Mobile:

<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>jQuery Mobile: Popup Window</title>
    <link rel="stylesheet" href="" />
    <script src=""></script>
    <script src=""></script>
    <div data-role="page">
            <div data-role="header"><h1>Dialog Test</h1></div>
            <div data-role="content">
                    <p><a href="#internal-popup" data-rel="dialog">Open hidden content as popup</a></p>
        <div data-role="footer">Copyright</div>
    <div data-role="page" id="internal-popup">
            <div data-role="content">
            <img src=”/path-to/image.jpg” />
            <p>Image caption can go here</p>

Dialog (or popup) windows include a close button by default that leads you back to the parent web page. The nice thing about this is that you don’t need to program a close button or add any extraneous code to your web page.

  • + Share This
  • 🔖 Save To Your Account