I, IFRAME Article
//Parent object to get the value of the Child Window
// ObjectidIs the window identifier,ContentidYeselementID
Function getvalue (objectid, contentid)
{
VaR isie = (navigator. appname = 'Microsoft Internet Explorer ')
If (isie)
{//If yesIE
Alert(document.frames(objectid).doc ument. getelementbyid (contentid). innerhtml );
}
Else
{//If yesFF
Alert (document. getelementbyid (objectid). contentdocument. getelementbyid (contentid). innerhtml );
// FFNot SupportedInnertext;The solution is as follows:
// If (document. All ){
//Alert (document. getelementbyid ('did1'). innertext );
//} Else {
//Alert (document. getelementbyid ('div1 '). textcontent );
//}
}
}
//The parent object assigns a value to the Child Window.
// ObjectidIs the window identifier,ContentidYeselementID
Function setvalue (objectid, contentid)
{
VaR isie = (navigator. appname = 'Microsoft Internet Explorer ')
If (isie)
{//If yesIE
Document.frames(objectid).doc ument. getelementbyid (contentid). innerhtml ="I amIEAssigned by the parent window";
}
Else
{//If yesFF
Document. getelementbyid (objectid). contentdocument. getelementbyid (contentid). innerhtml ="I amFFAssigned by the parent window";
}
}
//&&&&&&&&&&&&&&&&&&&&Public method end&&&&&&&&&&&&&&&
1.Parent window operation on Child Window
Refresh:
Document. getelementbyid ("iframeid"). src = Document. getelementbyid ("iframeid"). SRC + "? _ = "+ Math. Random ();
The above method sometimes needs toSRC.
Valid value:
//The parent window obtains the value of the Child Window.
Getvalue ("iframe1", "iframediv ");
Assignment:
//Set the value of window elements in the parent window.;
Setvalue ("iframe1", "iframediv ");
2.Child Window operation parent window
Refresh:
(1),Window. Parent. Location. href = Window. Parent. Location. href;
(2),Window. Parent. Location. Reload ();
(3)You can add
Valid value:
Alert(registry.parent.doc ument. getelementbyid ("iframediv"). innerhtml );
Assignment:
Response response parent.doc ument. getelementbyid ("iframediv"). innerhtml ="I am from the subwindowIFRAMEPassed Value";
Close:
Window. Parent. Opener = NULL ;//If this statement is not added, the system will prompt to close the inquiry window.;
Window. Parent. Close ();
II,Window. OpenArticle
1.Parent window operation on Child Window
Open:
VaR win = NULL;
Win = Window. Open ("open.html", "win", "width = 200, Height = 200 ");
Maximize:
//Window Maximization
Function sonmaximize ()
{
If (WIN & Win. Open &&! Win. Closed)
{
Win. moveTo (-4,-4 );
Win. resizeTo (screen. availwidth + 8, screen. availheight + 8 );
} Else {
Alert ('Window not opened or closed');
}
}
Minimize:
//Minimize windows
Function sonminimize ()
{
If (WIN & Win. Open &&! Win. Closed)
{
Win. resizeTo (0, 0 );
Win. moveTo (0, window. Screen. width );
} Else {
Alert ('Window not opened or closed');
}
}
Close:
//Close Window
Function closeson ()
{
If (WIN & Win. Open &&! Win. Closed)
{
Win. Opener = NULL;
Win. Close ()
} Else {
Alert ('Window not opened or closed');
}
}
Refresh:
//Refresh
Function refreshson ()
{
If (WIN & Win. Open &&! Win. Closed)
{
Win. Location. Reload ();
Win. Focus ();
} Else {
Alert ('The window has not been opened or closed');
}
}
View the window size:
Function viewsonsize ()
{
If (WIN & Win. Open &&! Win. Closed)
{
Alert(win.doc ument. Body. clientwidth + '* '{win.doc ument. Body. clientheight );
Win. Focus ();
} Else
{
Alert ('Window not opened or closed');
}
}
Valid value:
Alert(registry.doc ument. getelementbyid ("opendiv"). innerhtml );
Assignment:
Win.doc ument. getelementbyid ("opendiv"). innerhtml ="I am the value from the parent window";
2.Subwindow operation window
Refresh:
Window. opener. Location. Reload ();
//The following method can also be used:
// Window. Parent. Location. href = Window. Parent. Location. href;
Close this window:
//Close this window
Function closewindow ()
{// Window. opener. Opener = NULL;
Window. Close ();
}
Close parent window:
//Close parent window
Function closeparent ()
{//Firefox does not work,To work. Use the following method
//OpenFirefox,In the address bar, enterAbout: config
//FindDom. allow_scripts_to_close_windowsThis item is changedTrue
VaR isie = (navigator. appname = 'Microsoft Internet Explorer ')
If (isie ){//If yesIE
Window. opener. Opener = NULL;
Window. opener. Close ();
Window. Close ();
} Else {
Alert ("Firefox cannot be closed directly.;The following settings are required:1.OpenFirefox,In the address bar, enterAbout: config; 2.FindDom. allow_scripts_to_close_windowsThis item is changedTrue ");
}
}
Valid value:
Alert(registry.opener.doc ument. getelementbyid ("opendiv"). innerhtml );
Assignment:
Registry.opener.doc ument. getelementbyid ("opendiv"). innerhtml ="I am from the subwindowOpenPassed Value";
Iii. Modal window
1.Parent window operation subwindow
Parent windowJSCode:
VaR parvalue ="The variable value in the parent window is displayed.";
VaR Hao ="Hao Jianwei";
Function showdailog (pagehref, title, height, width)
{
// -------------- LeftLocation
// Screen. availheightDeclares the available width of the display browser screen
VaR dleft = (screen. availheight-height)/2;
// -------------- TopLocation
VaR dtop = (screen. availwidth-width)/2;
//---------------
VaR sret = Window. showmodaldialog (pagehref, window, title, "scrollbars = yes; resizable = no; help = no; status = no; center = yes; dialogtop = 25; dialogleft = "+ dleft +"; dialogtop = "+ dtop +"; dialogheight = "+ height +" PX; dialogwidth = "+ width +" PX ;");
// -------- Return
If (sret = "refresh ")//The returned value is used to refresh the parent page.
{
Window. test = "true ";
Window. Location. Reload ();
Alert (window. test );
}
}
Function Test ()
{
Alert ("Method for successfully calling the parent window in the modal window");
}
2.Modal window operation parent window
VaR parentwin = Window. dialogarguments;
Refresh:
Parentwin. Location. Reload ();
Valid value:
Alert(parentwin.doc ument. getelementbyid ("showmodaldialogdiv"). innerhtml )//Obtain objects in the parent window
Alert ("I got the variable from the parent window.>>> "+ Parentwin. parvalue );//Get the variables in the parent window
Call parent windowJSMethod:
Parentwin. Test ();//Call the method in the parent window
Assignment:
Parentwin.doc ument. getelementbyid ("showmodaldialogdiv"). innerhtml ="I am from the subwindowShowmodaldialogPassed Value";
Close this window:
//Close this window
Function closewindow ()
{
Window. Parent. Close ();
}
Close the parent window:
//Close parent window
Function closemodal ()
{
VaR isie = (navigator. appname = 'Microsoft Internet Explorer ')
If (isie ){//If yesIE
Window. Parent. Parent. Close ();
// Parentwin. Opener = NULL;If you replace the preceding row with this line, the parent window cannot be closed,
Parentwin. Close ();
// Window. Parent. Close ();Only the modal window can be closed. Currently, onlyIE6Test
} Else {
Alert ("Firefox cannot be closed directly.;The following settings are required:1.OpenFirefox,In the address bar, enterAbout: config; 2.FindDom. allow_scripts_to_close_windowsThis item is changedTrue ");
}
}