JS window problem handling: a pop-up window to maintain the front display of several methods, and Window form object Open () and ShowModalDialog () usage

Source: Internet
Author: User

with window.open Open a window, how to make it always on top of the parent window, unless you click on its own set of the Close button, I tried onblur= "Self.focus" seems to be no use.

You can use:

Opened=window.open ("Demo.html", "Demo", "Left=80,top=60,width=640,height=480,help:no,resizable:no"); Opened.focus ();
Self.blur ();
}

http://www.javaeye.com/topic/347369

Method one: Pop-up window <body> code: onblur= "Self.focus ()":
<body onblur= "Self.focus ()" >
When you use this method, the focus is always on this pop-up window and cannot be manipulated in other windows, focus please don't come back.

*********************************************************************
Method Two: Use the ShowModalDialog method to establish the modal dialog box:
<script>
function Topwin () {
window.showModalDialog ("d:/window.html", "" "," Dialogwidth:300px;dialogheight:300px;scroll:no;status:no ")
}
</script>
<button onclick= "Topwin ()" > Open mode Window </button>
The effect of this method is the same as that of method one, pop-up window front end display, but can not do any operation in other windows, but also lose focus.

*********************************************************************

Method Three: Create a modeless dialog box using the showModelessDialog method:
<script>
function Topwin () {
Window.showmodelessdialog ("d:/window.html", "" "," Dialogwidth:300px;dialogheight:300px;scroll:no;status:no ")
}
</script>
<button onclick= "Topwin ()" > Open modeless window </button>
This method pops up the front end of the window, but can be manipulated in other windows. Hehe do this when also made a confused, in the pop-up window to add a close button, but write the JS function name is closed (), this is good, how to point this button is not so, puzzled for a while, finally the function name changed just OK. It seems that the name of the time is really not too popular, conflict. Ha ha

In addition, open the window in general and point the focus to the open window

function Opensubwindow (subwin,width,height) {
var winwidth = parseint (width)
var winheight = parseint (height)
var newwin = window.open (Subwin, "Subwindow", "width=" +winwidth+, height= "+winheight+", Status=no, Menubar=no, toolbar =no, Scrollbars=yes ");
Newwin.focus ();
}

About Window Form objects open () and ShowModalDialog () usage

http://www.javaeye.com/topic/188709

First, window.open () Support environment: javascript1.0+/jscript1.0+/nav2+/ie3+/opera3+ Two, basic grammar: window.open (pageurl,name,parameters) Where: Pageurl for the child window path name for the child window handle parameters for window parameters (separated by commas) Three, examples: <SCRIPT> <!--window.open (' page.html ', ' Newwindo W ', ' Height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, Resizable=no,location=no, Status=no ') Write a line--> </SCRIPT> script runs, Page.html will be opened in the new form NewWindow, wide 100, height 400, 0 pixels from the top of the screen, 0 pixels from the screen, no toolbar, no menu bar, no scroll bar, no resizing, no address bar, no status bar. Please compare. There are a number of other parameters that are commonly used in the example above, see Four. Four, each parameter yes/no also may use 1/0;pixel value as the concrete numerical value, the unit pixel. Parameters | Value Range | Description | | alwayslowered | yes/no | Specifies that the window is hidden behind all windows Alwaysraised | yes/no | The specified window is suspended above all windows depended | yes/no | Whether to close directories with the parent window | yes/no | NAV2 and 3 are visible in the column height | Pixel value | Window Height Hotkeys | yes/no | Set up a secure exit hotkey in a window without a menu bar Innerheight | Pixel value | Pixel height of the document in the window Innerwidth | Pixel value | Pixel width of the document in the window location | yes/no | is the location bar visible MenuBar | yes/no | Whether the menu bar is visible outerheight | Pixel value | Set the pixel height of the window (including the decorative border) outerwidth | Pixel value | Set the image of a window (including a decorative border)Vegetarian Width Resizable | yes/no | Whether the window size can be adjusted ScreenX | Pixel value | The pixel length of the window from the left edge of the screen ScreenY | Pixel value | The pixel length of the window from the edge of the screen scrollbars | yes/no | Whether the window can have scroll bars titlebar | yes/no | Whether the window topic bar is visible Toolbar | yes/no | Whether the window toolbar is visible in Width | Pixel value | Pixel width of window Z-look | yes/no | Whether the window floats on top of other windows when it is activated window.showModalDialog basic introduction: ShowModalDialog () (ie 4+ support) showmodelessdialog () (ie 5+ support) Window.sho The Wmodaldialog () method is used to create a modal dialog box that displays HTML content. The Window.showmodelessdialog () method is used to create a modeless dialog box that displays HTML content. How to use: Vreturnvalue = window.showModalDialog (sURL [, varguments] [, sfeatures]) Vreturnvalue = Window.showmodelessdialog ( sURL [, Varguments] [, sfeatures]) parameter description: surl--required parameters, type: string. The URL used to specify the document to display in the dialog box. varguments--optional parameter, type: Variant. Used to pass parameters to the dialog box. The parameter types passed are not limited, including arrays, and so on. The dialog box is window.dialogarguments to get the parameters passed in. sfeatures--optional parameter, type: String. Used to describe information such as the appearance of a dialog box, you can use one or more of the following, with a semicolon ";" Separated. 1.dialogHeight: Dialog height, not less than 100px,ie4 dialogheight and dialogwidth default unit is EM, and IE5 is PX, in order to facilitate its see, in the Definition of modal dialog box, with PX to do units. 2.dialogWidth: Dialog box width. 3.dialogLeft: The distance from the left of the screen. 4.dialogTop: The distance from the screen. 5.center: {Yes | No | 1 | 0}: The window is centered, the default yes, but the height and width can still be specified. 6.help: {yes | no | 1 | 0}: Show Help button, default yes. 7.resizable: {yes | no | 1 | 0} [ie5+]: can be changed size. Default No. 8.status: {yes | no | 1 | 0} [ie5+]: Whether the status bar is displayed. Default is yes[Modeless] or no[modal]. 9.scroll:{Yes | no | 1 | 0 | on | off}: Indicates whether the dialog box displays scroll bars. The default is yes. The following attributes are used in an HTA and are generally not used in general Web pages. 10.dialoghide:{Yes | no | 1 | 0 | on | off}: Dialog box is hidden when printing or printing preview. The default is No. 11.edge:{Sunken | raised}: Indicates the border style of the dialog box. Default is raised. 12.unadorned:{Yes | no | 1 | 0 | on | off}: default is No. Parameter pass: 1. To pass parameters to a dialog box, pass it through varguments. Type is not restricted, for a string type, the maximum is 4,096 characters. You can also pass objects, such as:-------------------------------parent.htm <mce:script type= "Text/javascript" ><!--var obj = new Object (); Obj.name= "51js"; window.showModalDialog ("modal.htm", obj, "dialogwidth=200px;dialogheight=100px"); --></mce:script> modal.htm <mce:script type= "Text/javascript" ><!--var obj = Window.dialogarguments alert ("The parameter you passed is:" + obj.name)//--></mce:script>-------------------------------2. Can pass Window.returnvalThe UE returns information to the window that opens the dialog box, and it can be an object, of course. For example:------------------------------parent.htm <mce:script type= "text/javascript" ><!--str = window.showModalDialog ("modal.htm", "dialogwidth=200px;dialogheight=100px"); alert (str); --></mce:script> modal.htm <mce:script type= "Text/javascript" ><!--window.returnvalue= "http://" Www.51js.com "; --></mce:script> currency defines a portion of Var psaddstr= "processid=" +processid+ "&addflag=" +isaddflag+ "&BZBH=" + vsbzbh+ "&bzmc=" +vsbzmc+ "&bzfh=" +vsbzfh+ "&jd=" +VSJD; var result=window.showmodaldialog ("Addsave.asp?") +psaddstr, "," dialogheight:250px;dialogwidth:250px;status:no; "); -----------------------------Use the summary-------------------------mode form var returnval=window.showmodaldialog (Url,window, " dialogwidth=220px;dialogheight=530px "); Note that the 2nd parameter passed as a window action is a pop-up form to access the properties or methods inside the parent window, accessed in the form of: Dialogarguments.parentfun () {}; ReturnValue is a return value, not a Document object, but a simple JavaScript object (string,date ...) window.returnvalue= "123"; then the returnval number is 123. Open pop-up form var obj=window.opeN (URL, ', ' location=no,menubar=no,scroll=yes,height=756px,width=940px,resizable=no,status=yes '); To access the parent page method: Window.opener.parfun () {} Note that obj is a reference to the pop-up form, and you can call the Obj.close () method to close the pop-up form.

http://www.javaeye.com/topic/112626

The summary of the article is as follows

Javascript Pop-up Summary http://e-ant.javaeye.com/blog/307650 Summary: child window creation and communication between parent window and child window http:// super-094.javaeye.com/blog/205905 How to refresh the parent page after the modal window closes http://www.javaeye.com/problems/2372

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.