[Usage] detailed use of showmodaldialog in JS

Source: Internet
Author: User

From:Http://hi.baidu.com/java6666/blog/item/40d0e4e8e7b9d734b90e2de3.html

Basic Introduction:
Showmodaldialog () (ie 4 + supported)
Showmodelessdialog () (ie 5 + supported)
The window. showmodaldialog () method is used to create a modal dialog box that displays HTML content.
The window. showmodelessdialog () method is used to create a non-modal dialog box that displays HTML content.
Usage:
Vreturnvalue = Window. showmodaldialog (Surl [, varguments] [, sfeatures])
Vreturnvalue = Window. showmodelessdialog (Surl [, varguments] [, sfeatures])
Parameter description:
Surl -- required parameter; Type: String. Specifies the URL of the document to be displayed in the dialog box.
Varguments -- optional parameter; Type: variant. Used to pass parameters to the dialog box. The passed parameter types are not limited, including arrays. Dialog Box passed

Window. dialogarguments to get the passed parameters.
Sfeatures -- optional parameter; Type: String. Used to describe the appearance and other information of the dialog box. You can use one or more of the following, separated by semicolons.
----------------
1. dialogheight: dialog box height, not smaller than 100px
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}: whether to center. The default value is yes, but the height and width can still be specified.
6. Help: {Yes | no | 1 | 0}: whether to display the Help button. The default value is yes.
7. resizable: {Yes | no | 1 | 0} [ie5 +]: whether the size can be changed. No by default.
8. Status: {Yes | no | 1 | 0} [ie5 +]: whether to display the status bar. The default value is Yes [modeless] or no [modal].
9. Scroll: {Yes | no | 1 | 0 | on | off}: whether to display the scroll bar. The default value is yes.

The following attributes are used in HTA and are not used in general web pages.
10. dialoghide: {Yes | no | 1 | 0 | on | off }:PrintOr whether the dialog box is hidden when the preview is printed. The default value is no.
11. Edge: {sunken | raised}: Specify the border style of the dialog box. The default value is raised.
12. unadorned: {Yes | no | 1 | 0 | on | off}: No by default.

Parameter transfer:
1. varguments is used to pass Parameters in the dialog box. The type is not limited. For string types, the maximum value is 4096 characters. Objects can also be passed, for example:
-------------------------------
Parent.htm
<SCRIPT>
VaR OBJ = new object ();
OBJ. Name = "51js ";
Window. showmodaldialog ("modal.htm", OBJ, "dialogwidth = 200px; dialogheight = 100px ");
</SCRIPT>
Modal.htm
<SCRIPT>
VaR OBJ = Window. dialogarguments
Alert ("the parameter you passed is:" + obj. Name)
</SCRIPT>
-------------------------------
2. You can use window. returnvalue to return information to the window that opens the dialog box. It can also be an object. For example:
------------------------------
Parent.htm
<SCRIPT>
STR = Window. showmodaldialog ("modal.htm", "dialogwidth = 200px; dialogheight = 100px ");
Alert (STR );
</SCRIPT>
Modal.htm
<SCRIPT>
Window. returnvalue = "http://homepage.yesky.com ";
</SCRIPT>

Common tips:

1. How can I leave a new window in the superconnection between showmodaldialog and showmodelessdialog?
Add <base target = "_ Self"> to the opened webpage. This sentence is generally placed between

Target = "" in the table at the same time must be blank.

2. How can I refresh the content in showmodaldialog and showmodelessdialog?
In showmodaldialog and showmodelessdialog, you cannot press F5 to refresh or bring up a menu. This depends on

Javascript. The following are relatedCode:

<Body onkeydown = "If (event. keycode = 116) {reload. Click ()}">
<A id = "reload" href = "filename.htm" style = "display: none"> reload... </a>

Replace filename.htm with the webpage name and place it in the webpage you opened. Press F5 to refresh the page.

Use with <base target = "_ Self">. Otherwise, press F5 to bring up a new window.

3. How to use JavaScript to close the window opened by showmodaldialog (or showmodelessdialog.
<Input type = "button" value = "close" onclick = "window. Close ()">
Also use <base target = "_ Self">. Otherwise, a new ie window will be opened and closed.

4. Math. Random and showmodaldialog.

When the pop-up page you set is fixed (as shown above)"Modal.htm" Page)Ie can easily download the next page (openpage.html) to the local file area without reloading,

For Dynamically Loaded pages, this often leads to misunderstandings. If data is not updated in time, it is not conducive to developer testing. Therefore, you can use the following method:

VaR strpage = "/medal.htm? Random = "+ math. Random ();

In this way, the strpage generated every time is different. The reason is self-evident.

 

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.