Advertisement
C_Volume2 Windows #80746

Modal Window

To create a modal window using JavaScript that supports full data entry capabilities. The window open function also has the ability to open the new window centered on the screen.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
<%
'------------------
' 
'------------------
%>
<html>
<HEAD>
	<TITLE>Modal Window Test</TITLE>
<script LANGUAGE="JavaScript"><!--
sticky_URL = "BuildQuery.asp"
ModalWin = null;
function openWin() {
	if (!ModalWin || ModalWin.closed) {
		ModalWin = window.open(sticky_URL,"ModalWin","resizeable=yes,scrollbars=yes,width=400,height=300");
	}
	else
	{
		ModalWin.focus();
	}
}
function FocusModalWin(){
	setTimeout(CheckModalWin, 50);
}
function CheckModalWin(){
	if (ModalWin && !ModalWin.closed) {
		ModalWin.focus();
	}
}
function go(url,iHeight,iWidth,sNewWindow,sModalWinName) {
	if (url=="Refresh")
	{
	top.location.href="default.htm";
	}
	else
	{
		if (document.all)
		  var xMax = screen.width, yMax = screen.height;
		else
		  if (document.layers)
		    var xMax = window.outerWidth, yMax = window.outerHeight;
		  else
		    var xMax = 640, yMax=480;
		// var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
		var xOffset = (xMax - iWidth)/2, yOffset = (yMax - iHeight)/2;
			
		if (sNewWindow=="new")
		{
			// window.open (url, null,"height=" +iHeight + ",width=" + iWidth + ",status=yes,toolbar=no,menubar=no,location=no");
			// ModalWin = window.open(sticky_URL,"ModalWin","resizeable=yes,scrollbars=yes,width=400,height=300");
			if (go.arguments.length==5) {
				if (!ModalWin || ModalWin.closed) {
					ModalWin = window.open (url, sModalWinName,"screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset+",height=" +iHeight + ",width=" + iWidth + ",status=yes,toolbar=no,menubar=no,location=no");
				}
				else
				{
					ModalWin.focus();
				}
			}
			else 
			{
				window.open (url, null,"screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset+",height=" +iHeight + ",width=" + iWidth + ",status=yes,toolbar=no,menubar=no,location=no");
			}
		}	
		else
		{
			location.href = url;
			// window.open (url , null,"height=450,width=600,status=yes,toolbar=no,menubar=no,location=no");
		}
	}
}
--></script>
</HEAD>
<BODY onFocus="FocusModalWin()" bgcolor="#FFFFFF" >
<input type=button value="Open Test 3" onclick="javascript:go('test3.htm', 300, 500,'new','winTest3');" title="Open Test 3">
<BR>
Click the button to open the modal window then attempt to click on this window again.
</BODY>
</HTML>
-- -CUT HERE FOR Make next few lines into test3.htm -------------------------
<html>
<HEAD>
	<TITLE>Modal Window now open</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
Success!!!! Try clicking on the parent window before you close this window.
<FORM NAME=cmdTest METHOD=POST ACTION=test.asp>
<INPUT TYPE=TEXT VALUE="TYPE HERE TEST" NAME=VAR1>
<INPUT TYPE=SUBMIT VALUE="SUBMIT" NAME=cmdSubmit>
</FORM>
</BODY>
</HTML>
Upload
Commenti originali (3)
Recuperato da Wayback Machine