Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1809 How do I make a modal window?

irt.org | Knowledge Base | JavaScript | Window | Q1809 [ previous next ]

Q1809 How do I make a modal window?

This code is a very simple example that will provide the functionality of a modal window under IE4 / NS4

One problem I have seen is that, if the main document does not take up the entire screen, then clicking outside your document will allow you to return to the main window. This is the reason for the table in the example below.

<HTML>
<HEAD>
<TITLE>Modal Windw Example</TITLE>
<SCRIPT>
var popWindow;

function PopDis(loc) {
  popWindow = window.open (loc,'popdis' ,'status=0,toolbar=0,height=450,width=510,location=0,menu=0,resizable=0,scrollbars=1');
  popWindow.opener = self;
}

function checkPop () {
  if ((popWindow) && (!popWindow.closed)) {
    popWindow.focus();
  }
}
</SCRIPT>
</HEAD>

<BODY onFocus="checkPop();">

<table width=100% height=100%><tr><td>
<form>
<input>
</form>

<A href="javascript:PopDis('test2.html')">Open a modal window</a>

</td></tr></table>

</body>
</html>

Submitted by Leigh Craig-Browne


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.