javascript modal window-value

2010-06-22  来源:本站原创  分类:Web  人气:271 

Javascript-value between the two forms to achieve code
There is also a function window.showModalDialog javascript can also open a new form, but he opened a modal window, how the parent form and child form in between the pass worth it? We look at the function definition: vReturnValue = window.showModalDialog (sURL [, vArguments] [, sFeatures])
Parameters:
sURL - required parameter, type: string. Used to specify the dialog box to display the document's URL.
vArguments - optional parameters, type: variant. Used to pass parameters to the dialog box. Parameter type passed open, including an array of other. Dialog box to get passed through window.dialogArguments incoming parameters.
sFeatures - optional parameters, type: string. Used to describe the appearance of the dialog box and other information, you can use the following one or a few, with a semicolon ";" to separate.
dialogHeight: dialog height, not less than 100px, IE4 in dialogHeight and dialogWidth default units are em, but IE5 is px, to facilitate their view, the way in defining the modal dialog box, make use of px units.
dialogWidth: dialog width.
dialogLeft: the distance from the screen to the left.
dialogTop: the distance from the screen.
center: (yes | no | 1 | 0): the window is centered, default yes, but you can specify the height and width.
help: (yes | no | 1 | 0): whether to display the Help button, default yes.
resizable: (yes | no | 1 | 0) [IE5 +]: it can be resized. Default no.
status: (yes | no | 1 | 0) [IE5 +]: whether to display the status bar. The default is yes [Modeless] or no [Modal].
scroll: (yes | no | 1 | 0 | on | off): specify whether to display the dialog box scroll bar. The default is yes.
Such as: "dialogWidth = 200px; dialogHeight = 100px"
Therefore, we can window.dialogArguments parameters by value between the two forms, such as the following two pages: FatherPage.htm:
Code:

<script type="text/javascript">
function OpenChildWindow()
{
window.showModalDialog('ChildPage.htm',document.getElementById('txtInput').value);
}
</script>
<input type="text" />
<input type="button" value="OpenChild" /> 

ChildPage.htm:
 Code is as follows  :
<body onload="Load()">
<script type="text/javascript">
function Load()
{
document.getElementById('txtInput').value=window.dialogArguments ;
}
</script>
<input type="text" />
</body> 

 The above just passing a simple string, we can also pass an array  , If  :FatherPage.htm:
XML-Code:
 Code is as follows  :
<script type="text/javascript">
function OpenChildWindow()
{
var args = new Array();
args[0] = document.getElementById('txtInput').value;
window.showModalDialog('ChildPage.htm',args);
}
</script>
<input type="text" />
<input type="button" value="OpenChild" />ChildPage.htm:
XML-Code:
<script type="text/javascript">
function Load()
{
document.getElementById('txtInput').value=window.dialogArguments[0] ;
}
</script> 

 Similarly we can also pass an object, such as  :FatherPage.htm:
XML-Code:
 Code is as follows  :
<script type="text/javascript">
function OpenChildWindow()
{
var obj = new Object();
obj.name = document.getElementById('txtInput').value;
window.showModalDialog('ChildPage.htm',obj);
}
</script>
<input type="text" />
<input type="button" value="OpenChild" /> 

ChildPage.html:
XML-Code:
 Code is as follows  :
<script type="text/javascript">
function Load()
{
var obj = window.dialogArguments;
document.getElementById('txtInput').value=obj.name ;
}
</script> 

 The above are from parent to child form, then how to pass a value from the subform to the parent form by value?   ? In fact, through the window.returnValue can obtain the value of the child form  ,window.returnValue As with the window.dialogArguments  , Can be any string variable, including  , Array, object, etc.  . If  :FatherPage.html:
XML-Code:
 Code is as follows  :
<script type="text/javascript">
function OpenChildWindow()
{
var obj = new Object();
obj.name = document.getElementById('txtInput').value;
var result = window.showModalDialog('ChildPage.htm',obj);
document.getElementById('txtInput').value = result.name;
}
</script>
<input type="text" />
<input type="button" value="OpenChild" /> 

ChildPage.html:
XML-Code:
 Code is as follows  :
<body onload="Load()">
<script type="text/javascript">
function Load()
{
var obj = window.dialogArguments;
document.getElementById('txtInput').value=obj.name ;
}
function SetValue()
{
var obj = new Object();
obj.name = document.getElementById('txtInput').value;
window.returnValue = obj;
window.close();
}
</script>
<input type="text" />
<input type="button" value="SetFather" />
</body> 
相关文章
  • JavaScript modal window, multi-browser, multi-modal windows exist, to support localized modes, can easily drag position, support for custom styles 2010-07-20

    ////////////////////////////////////////////////// ///////////// ////////////////////////////////////////////////// ///////////// / / / / Javascript modal window ///////////////////////////////////////// / / / / Version: 2.2 /////////////////////////

  • The modal window using javascript 2010-06-05

    2009-07-17 Need to pop up in the web page of some modal windows, for how to apply generally to do a bit summary. Open modal window var result = showModalDialog("b2.htm","dialogWidth:270px;dialogHeight:140px;status:'no'"); // Displays a

  • Turn: javascript pop-up window code complete 2010-01-04

    How to use various forms of Web pop-up window, I think we mostly know more, but that a wide range of pop-up window out how the practice, we today learn about: 1. Shells Kai a full-screen window <html> <body onload="window.open('http://www.ku

  • showdialog modal window POST method 2010-04-09

    showdialog the post in IE8 is to open a new window, and Firefox different. So if the modal window to submit to the background of some operations will cause beyond the control of closed windows. The solution is to <head> </ head> in adding <

  • javascript modal window-value 2010-06-22

    Javascript-value between the two forms to achieve code There is also a function window.showModalDialog javascript can also open a new form, but he opened a modal window, how the parent form and child form in between the pass worth it? We look at the

  • Summary of JavaScript (Iframe.window.open.window.showModalDialog) between the parent window and child window operation 2010-09-29

    A, Iframe articles //&&&&&&&&&&&&&&&&&&&& Public method start &&&&&&&&&&&&&&& / / Get parent value of child window

  • JavaScript中window.showModalDialog()用法详解 2014-07-15

    这篇文章主要介绍了JavaScript中window.showModalDialog()用法详解,需要的朋友可以参考下 今天在项目中用到了弹出子窗口,就想到了用JavaScript实现的两种方法,一个是window.open();一个是window.showModalDialog()方法,后者是存在父子关系的一种弹出窗口,只有子窗关闭,父窗口才激活,并且可以传送参数和返回值.正好又温习一遍用法,顺便在此记录过程中遇到的问题. 基本介绍: showModalDialog() (IE 4+ 支持)

  • Modal window in web application 2010-03-27

    In web development, many parts of the modal pop-up windows may need to carry out treatment, but the modal window, the page calls required to submit a form, often will pop up a new page or some other hostile influence. Here we offer two approaches to:

  • Ask: modal window dTree solution 2010-03-30

    Functional Requirements Description: In the modal window to display a tree structure, and select the node back to the parent form. Is currently experiencing problems: In the modal window, you can load the tree, but in the selection of nodes when the

  • Top Javascript code window 2010-03-16

    Top Javascript code window: Makes the current code file can not be nested in another frame if (top.location! = self.location) ( top.location = self.location; )

  • Summary JavaScript (Iframe.window.open.window.showModalDialog) between the parent window and child window operation 2010-03-26

    Some time ago, has been shuttling the three operations, think of the future will be used, simply finishing down for their future view. Also to share with you! Considered useful in the following write their own operations and code. For the first time

  • Ask: modal window solution dTree 2010-03-30

    Functional Requirements Description: In the modal window to display the tree structure and select the node to return to the parent form. Current problems: the normal mode you can load the tree window, select the node in time, modal window, the page t

  • JavaScript child window parent window and the interaction between 2010-06-06

    // The parent object is the value of a child window //ObjectID Is Windows identity, ContentID is element ID function GetValue(ObjectID,ContentID) { var IsIE = (navigator.appName == 'Microsoft Internet Explorer') if(IsIE){// If you are IE alert(docume

  • openDialog () open a modal window (Firefox) 2010-06-13

    openDialog () is used and the open () function is similar to Firefox, simply open the modal window to set the window properties to add a "modal" parameter can be: openDialog(url,arg,"centerscreen,modal");

  • javascript capture window close event (change) 2010-07-13

    javascript capture window close event, there are two ways 1. Using javascript to redefine window.onbeforeunload () event In the javascript function can be defined in a function window.onbeforeunload () (alert ("closing window")) alert () event w

  • Modal window issues that need attention 2010-08-10

    1, modal window refresh Open the child page the parent page: var url; var name; var iWidth; var iHeight; if(iWidth==''){ iWidth = 400; } if(iHeight==''){ iHeight = 600; } var iTop = (window.screen.availHeight-30-iHeight)/2; var iLeft = (window.screen

  • download asp.net modal window solution 2011-01-07

    Ideas, put the page in a modal window film reservoir iframe. First, we create a modal window, modal window a.aspx <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quo

  • About use of modal window, modal window form submission problem solving 2011-05-31

    In a number of web pages need to pop up modal window, how to do a little summary of general application. Open modal window var result = showModalDialog ("b2.htm", "dialogWidth: 270px; dialogHeight: 140px; status: 'no'"); / / display di

  • 重写javascript中window.confirm的行为 2013-12-31

    javascript中window.confirm这个方法很好用,可以弹出一个确认对话框.但有一个问题是,它默认的情况下,将选中那个"确定"按钮,当用户有意无意的在键盘回车,就是说按下Enter键的时候,就会自动返回true.在很多时候其实我们不希望这样 javascript中window.confirm这个方法很好用,可以弹出一个确认对话框 我们之所以弹出这个对话框,可能就是因为该操作很危险,所以要用户确认.但如果默认选择"确定",则可能违背了这个原则. 另外,c

  • javascript使用window.open提示"已经计划系统关机"的原因 2014-02-04

    这篇文章主要介绍了javascript使用window.open提示"已经计划系统关机"的原因,本文得出结论是安装了系统更新或其它原因,要把系统重启时才会提示这个问题,所以,遇到这个问题,重启你的电脑吧 javascript调用window.open打开网站的时候,IE浏览器下报错:已经计划系统关机,提示如图: 百度找了下都是莫名其妙的自动好了,可以查看这个帖子:诡异的JS,已经计划系统关机错误. 于是改用谷歌搜索相关英文内容,serverfault.com上也有人碰到过这个问题,满意