Click here to Skip to main content
13,899,680 members
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 7 Jul 2016
Licenced CPOL

Nested Modal Dialogs using Bootstrap

, 20 Feb 2019
Rate this:
Please Sign up or sign in to vote.
This project will show how to create nested modals.


The goal of this project is to show how to create nested modals. Each modal is created from another page using an iframe. This approach lets you dynamically load as many modals as you need. Unzip to a firtal directory and point your browser to Default.htm.

Most code is contained in BsModal.js file. This file will let you:

  1. Open a URL in a modal dialog using iFrame
  2. Create nested dialogs
  3. Show spinner while the page loads
  4. Open an external page in full screen dialog
  5. Move the modal dialog around the page

The code uses three external libraries:

  1. jQuery (1.12.3)
  2. Bootstrap (3.3.6)
  3. Font-awesome (4.4.0)

Using the Code

To use this code, include BsModal.js file in the page that creates the first dialog. The key function is ShowModal(). It accepts the following parameters:

sUrl URL of the page to be loaded
iWidth width of the modal. Optional. When bank window width will be used
iHeight height of the modal. Optional. When bank window height will be used
oWin windows object of the calling modal page. Optional

From the main page (Default.htm) ShowModal() function can be used like this:

<input type="button" class="btn btn-info" value="Open Modal1.htm"

From a dialog page, the ShowModal() function can be used like this:

<input type="button" class="btn btn-info" value="Open Modal2.htm"

A modal dialog can close by calling HideModal() function like:

<button type="button" class="btn btn-default" onclick='parent.HideModal()'>Cancel</button> 


  • 7th July, 2016: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Igor Krupitsky
Web Developer
United States United States
Igor is a business intelligence consultant working in Tampa, Florida. He has a BS in Finance from University of South Carolina and Masters in Information Management System from University of South Florida. He also has following professional certifications: MCSD, MCDBA, MCAD.

You may also be interested in...


Comments and Discussions

QuestionType 'Global.BootstrapModals.My.MySettings' is not defined. Pin
truword22-Feb-19 2:29
professionaltruword22-Feb-19 2:29 
AnswerRe: Type 'Global.BootstrapModals.My.MySettings' is not defined. Pin
truword22-Feb-19 4:33
professionaltruword22-Feb-19 4:33 
PraiseNice job Igor Pin
Bud Staniek21-Feb-19 10:37
memberBud Staniek21-Feb-19 10:37 
QuestionWhere is the code? Pin
Andreas Kroll12-Jul-16 0:00
memberAndreas Kroll12-Jul-16 0:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190306.1 | Last Updated 20 Feb 2019
Article Copyright 2016 by Igor Krupitsky
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid