Showmodaldialog and IE7 dialog box styles

Source: Internet
Author: User

Window. showmodaldialog (URL, dialogargments. features) opens a new window

The URL is the name of the webpage to be enabled.
Dialogargments is a set parameter that is passed to the new window webpage. It can be of any data type.
Similar to open (), feature is a format setting. The call format is featurename1: featurevalue1 :( semicolon) featurename2: featurevalue2:

I will not elaborate on the specific parameters of feature. I should know the usefulness of the parameters by name.
Certer, dialogheight, dialogleft, dialogtop, dialogwidth, help (whether to display the Help button, the same below), status, resizeable
The value = 1 is yes, and 0 is no.

I think the most important thing is dialogargments, which can pass values to new windows.
The second important is its return value window. returnvalue. You can return a value of any type before the window opened by showmodaldialog is closed.
Example:

<Script language = "JavaScript">...
Function show ()...{
VaR sret = commandid showmodaldialog('a.html ', 'title', 'scrollbars = no; resizable = no; help = no; status = no; dialogtop = 25; dialogleft = 0; dialogheight = 350px; dialogwidth = pixel PX ;');
If (sret = "refresh ")
...{
Window. Location. Reload ();
}

}
</SCRIPT>
<Input name = "" type = "button" onclick = "show ();" value = "open"/>

<Script language = "JavaScript">...
Function al ()...{
Alert ("disabled ");
Window. returnvalue = "refresh ";
Window. Close ();
}
</SCRIPT>
<Input name = "" type = "button" onclick = "Al ();" value = "close"/>

Next, let's explain how to use this function in IE7. By the way, IE7 is very rigorous in tag verification. Previously, the <base target = "_ Self"/>

<Title> title </title>
<Base target = "_ Self"/>

Otherwise, it will not be valid. Remember! Okay. Let's explain the window size below.

 

1. Modal window adaptation:
Define window. open and window. when showmodaldialog is used to open a Web page dialog box, the window size and style are different in windows and IE of different versions.
In IE7, the status bar is quite different. The main content is retained by default (for details) and a read-only address bar is added. the minimum size of the window is limited to 250*150:

As shown in: In IE7, the height defined is only the height of the form content, and the height of the status bar and address bar is not counted. IE6 contains the height of the status bar and address bar. Therefore, based on different operating systems and IE versions, the highly adaptive JS Code is as follows:

/**
* Adjust the modal window height.
* Depending on the operating system and IE versions, reset the window height to avoid the appearance of the scroll bar.
*/
Function resetdialogheight (){
If (window. dialogarguments = NULL ){
Return; // ignore the non-modal window
}

VaR UA = navigator. useragent;
VaR Height = Document. Body. offsetheight;
If (UA. lastindexof ("MSIE 6.0 ")! =-1 ){
If (UA. lastindexof ("Windows NT 5.1 ")! =-1 ){
// Alert ("xp. ie6.0 ");
VaR Height = Document. Body. offsetheight;
Window. dialogheight = (height + 102) + "PX ";
}
Else if (UA. lastindexof ("Windows NT 5.0 ")! =-1 ){
// Alert ("w2k. ie6.0 ");
VaR Height = Document. Body. offsetheight;
Window. dialogheight = (height + 49) + "PX ";
}
}
}

Add the following code to the modal window: // Adjust the height of the system and its IE version after loading the window
Window. onload = resetdialogheight;

2. When the mode window in IE7 is submitted, the window is opened:
In ie 7.0, the location of the <base target = '_ Self'> attribute in the modal window is more strict. The <base> label must be placed in the

<HTML>
<Head>
<Title> title </title>
<Base target = "_ Self"/>
......
</Head>
<Body onload = "pageclose ();" scroll = "no">
......
</Body>
</Html>

 

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.