showModelessDialog

王朝百科·作者佚名  2012-04-15
窄屏简体版  字體: |||超大  

showModelessDialog创建一个非模态对话框,显示指定的HTML/PHP/ASP等类型文件。

基本介绍showModelessDialog() (IE 5+ 支持)

window.showModelessDialog() 方法用来创建一个显示HTML内容的非模态对话框。

使用方法vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])[1]

使用实例:(两个文件放在同一个目录下)

1 . showModelessDialogEX.htm 文件代码:

<head>

<html>

<head>

<title>showModelessDialogEX.htm</title>

<script>

var sUserName="";

/*------------------------------------------------------------

Supplying the window object as a parameter allows for declaring the global

variable, sUserName, and using it to return information from the modeless

dialog box.

------------------------------------------------------------- */

function fnCallDialog()

{

showModelessDialog("myDialog.htm",window,"status:false;dialogWidth:300px;dialogHeight:300px");

}

/*-------------------------------------------------------------

The fnUpdate function takes the value passed into sUserName in myDialog.htm

to update the span text on this page. This function is called in both

fnGetInfo and fnCancel functions in myDialog.htm.

-------------------------------------------------------------*/

function fnUpdate()

{

oName.innerText = sUserName;

}

</script>

</head>

<body>

<p>Enter your first name: <span id="oName"

style="color:red;font-size:24">Joan</span></p> <input type="button"

value="Display Modeless Dialog" onclick="fnCallDialog()">

</body>

</html>

2 . myDialog.htm文件代码:

<html>

<head>

<title>myDialog.htm</title>

<script>

/* -------------------------------------------------------------

This function makes use of the dialogArguments property of the

window object. dialogArguments allows the global variable sUserName

to feed the value supplied to the input in this dialog box back to

the window that called it.

---------------------------------------------------------------- */

function fnGetInfo()

{

var sData = dialogArguments;

sData.sUserName = oEnterName.value;

sData.fnUpdate();

}

/* -------------------------------------------------------------

This function cleans up in case the user has clicked the

Apply button before canceling.

---------------------------------------------------------------- */

function fnCancel()

{

var sData = dialogArguments;

sData.sUserName = "Joan";

sData.fnUpdate();

}

</script>

</head>

<body>

<label FOR="oEnterName" accesskey="f">Enter your

<span style="text-decoration:underline">F</span>irst Name</label>

<input id=oEnterName><br><br>

<input value="Apply" type=button onclick="fnGetInfo();">

<input value="Ok" type=button onclick="fnGetInfo();window.close();">

<input value="Cancel" type=button onclick="fnCancel();window.close();">

</body>

</html>

参数说明sURL -- 必选参数,类型:字符串。用来指定对话框要显示的文档的URL。

vArguments -- 可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。

sFeatures -- 可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。可选字符串dialogHeight:sHeight

可选字符串,指定对话框窗口的修饰,使用与一个或多个值以下分号分隔:

dialogHeight:sHeight

设置对话框窗口的高度(见备注默认度量单位)。

dialogLeft:sXPos dialogLeft: sXPos

设置对话框窗口相对于桌面左上角的左侧位置。

dialogTop:sYPos dialogTop:sYPos

设置对话框窗口相对于桌面左上角的榜首位置。

dialogWidth:sWidth dialogWidth:sWidth

设置对话框窗口的宽度(见备注默认度量单位)。

center:{ yes | no | 1 | 0 | on | off }

中心指定是否要在桌面对话窗口。 默认为 yes。

dialogHide:{ yes | no | 1 | 0 | on | off }

指定对话框窗口是否隐藏在打印或使用打印预览。此功能只有当一个对话框是从信任的应用程序打开。默认是no。

edge:{ sunken | raised }

指定对话框窗口边缘风格。默认是raised 。

resizable:{ yes | no | 1 | 0 | on | off }

指定对话框窗口中是否有固定的尺寸.默认是no。

scroll:{ yes | no | 1 | 0 | on | off }

指定对话框窗口是否显示滚动条。默认为 yes。

status:{ yes | no | 1 | 0 | on | off }

指定对话框窗口是否显示状态栏。默认为yes不受信任的对话窗口和窗口不信任的对话。

unadorned:{ yes | no | 1 | 0 | on | off }

指定对话框窗口是否显示边框的窗口浏览器。此功能只有当一个对话框是从信任的应用程序打开。默认是no。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航