- Menu scripts
- Window scripts
- Calendar scripts
- Gallery scripts
- Form widgets
- Tab view scripts
- Table widgets
- Drag and drop
- Folder trees
- Tooltips
- AJAX scripts
- Content Effects

- Misc scripts
- Javascript games
- Chess widgets
- DHTML Suite
- Resources
- cbolson.com
Download modal message script
Download files
You can download the entire script from this Zip file.
Files included in the package:
- demo-modal-message.html = Demo file
- js/modal-message.js = Main Javascript file
- js/ajax.js = Ajax (Library from http://twilightuniverse.com/projects/sack)
- js/ajax-dynamic-content.js = JS file from the Ajax dynamic content script.
- css/demos.css = CSS file the demos
- css/modal-message.css = CSS file needed in the script
Configuration
This script displays a modal message at the center of your browser window. When this message is displayed, all the other controls on your page will be disabled.
This is how it works:
Create object of class DHTML_modalMessage
messageObj = new DHTML_modalMessage(); // We only create one object of this class
Now, you can use some other methods to specify what to show and the appearance of the dialog box. These are some of the important methods:
setSource()
Specify path to external file. The content of this external file will be displayed inside the box. Argument to this method is:
- relative path to file(String)
Example: messageObj.setSource("include/myMessage.html");
setHtmlContent()
Specify static HTML content. Argument to this file is:
- HTML content(String)
Example: messageObj.setHtmlContent("This is <B>My</B> message");
setSize()
Sets the size of the message box. Arguments to method are:
- width(int) - Width of box
- height(int) - Height of box
Example: messageObj.setSize(500,300);
display()
Displays the message box. This method makes the message box appear on the screen. This method doesn't take any arguments.
close()
Hides the message box. This method removes a message box appear from the screen. This method doesn't take any arguments.
There are also some other methods you can use. Look at the comments above the method in modal-message.js for information about these
Comments
Post your comment
Please wait...



Thanks for your good job.
Sebastien Julien
Solution Media Canada
Almost all scripts are created in-house. By sending a message to post[at]dhtmlgoodies.com, you will get in touch with the author.
However the Javascript only works for the FIRST time you pop-up the dialog box and not for any subsequent time.
What is going wrong? I have a modal box I made that heavily uses javascript and it works the first time but not any subsequent times.
Thanks for your examples, I have used a few things from this website and I think it is great.
Since i've installed Internet Explorer 9, my modal windows don't works.
Have got a solution to resolve that bug ?
I don't like IE but i'm obligate to verify compatibility with other navigator.
With FireFox and Google Chrome, it's all right.
Only with compat. mode on..
Any solutions?
i really like your script but unfortunately I'm stuck in a problem here. How i could add scroll if the height is bigger than my screen?
Any help will be appreciated , thank you
I downloaded and when I tried the demo, for below examples, it didn't worked
Message from url (example 1)
Message from url (example 2)
Alternative confirm dialog (example 3)
Is this demo require to execute in server or can be executed in any static location.
Thanks in advance.
Can someone confirm that the download currently available on this page works on IE 9 official release?
Thanks,
Matt
I've just rechecked. The zip file contains the latest modal-message.js file. Please clear your cache and try to download the file again.
line 160 in the new modal-message.js file should look like this:
this.iframe = document.createElement('IFRAME');
Thanks a lot for a great tool!
Matt
Correcting to 100% or less fixes this issue. Not important to me but thought you may wish to know. Bizarrely, although it works fine at any zoom in FF4, resetting to normal retains a thicker border round the popup.
Thanks for a great piece of work,
Calum
in IE 9
Text :DOM Exception:INVALID_CHARACTER_ERR(5)
Thanks
Sapan
I get the same problem: "loading content, please wait"
constantly only for dynamic content.
any resolves??
But too I want to know how we can refresh automticaly the parent page of the modal message script on close ?
Thanks
In the Demo for "the Message from url (example 1)", if we choose Close or Send it does the same things, but how we can proceed to send input or texarea to update a database and after refresh the page behind the the modal message ?
Thanks a lot
To troubleshoot this, either comment out the script and reload (the popup should display without that error) or open the popup page directly in your browser rather than click on the hyperlink to it; any scripting error will display as you would expect.
(in particular the height, 180)? I'm using your excellent script to display poems on a site, however they are all different lengths so require different height (and width if possible). Please explain clearly as I'm a n00b! Thanks in advance, and thanks for all the great codes!
I experience the same problem, regarding "loading content, please wait", allthough I run everything from the server.
Can anyone give a hint pls.
Thanks in advance.
Sorry for the newbie question. I'm trying to create the modal popup when someone clicks on an image. But I am unsure to how exactly I should implement this. I have uploaded all the files. And I modified the <a href></a> for the image to look something like this -
<a href="#" onclick="displayMessage('./includes/demo-modal-message-1.inc');return false"><img src="./images/button.png" style="border:0px;" /></a>
But when I click nothing happens. What should I do?
I checked your demo in IE7. your demo worked well. but when i using downloded files in Localhost it wasnt work. why?/ please answer my question and save a LIFE! (: