메뉴 건너뛰기

Dev tips

JavaScript [js] showModalDialog Method

taknim 2011.12.05 23:58 조회 수 : 10091 추천:1670

http://blog.naver.com/skyalzza/1189993

showModalDialog Method


Creates a modal dialog box that displays the specified HTML document.

Syntax

vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])

Parameters

sURL Required. String that specifies the URL of the document to load and display.
vArguments Optional. Variant that specifies the arguments to use when displaying the document. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values passed by the caller from the dialogArguments property of the window object.
sFeatures Optional. String that specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:
dialogHeight:sHeight Sets the height of the dialog window (see Remarks for default unit of measure).
dialogLeft:sXPos Sets the left position of the dialog window relative to the upper-left corner of the desktop.
dialogTop:sYPos Sets the top position of the dialog window relative to the upper-left corner of the desktop.
dialogWidth:sWidth Sets the width of the dialog window (see Remarks for default unit of measure).
center:{ yes | no | 1 | 0 | on | off } Specifies whether to center the dialog window within the desktop. The default is yes.
dialogHide:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. The default is no.
edge:{ sunken | raised } Specifies the edge style of the dialog window. The default is raised.
help:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the context-sensitive Help icon. The default is yes.
resizable:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window has fixed dimensions. The default is no.
scroll:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays scrollbars. The default is yes.
status:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays a status bar. The default is yes for untrusted dialog windows and no for trusted dialog windows.
unadorned:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the border window chrome. This feature is only available when a dialog box is opened from a trusted application. The default is no.

Return Value

Variant. Returns the value of the returnValue property as set by the window of the document specified in sURL .

 

[부모창]

   var modifyArg = new Array();
   modifyArg[0] = window;   //부모창 자체를 모달로 넘긴다.
   var sFeatures = "dialogWidth:200px;dialogHeight:200px;scroll:no;center: yes; edge: raised; help: no; status: no;";
   window.showModalDialog( "./aaa.asp", modifyArg, sFeatures );


 

[모달창]

var param = window.dialogArguments; //모달창에서 부모창의 인자값을 받는다.

var parentWin = null ;  //부모창 자체를 받을 변수

 param[1] = null;
 try {
    parentWin = param[0];
   } catch ( e )
   {
    parentWin = null;
   }

window.returnValue = 1;   //띄워지는 창에(부모창에) 반환할 값을 설정해 준다.