A few days ago, I checked dbnetgrid and found that the pop-up window can automatically change its size according to the window content.CodeThe code below plays a role.
<Script language = "JavaScript">
<! --
Window. setTimeout (sizedialog, 1 );
Function sizedialog ()
{
Dialogheight = (parseint (layout. offsetheight) + 30) + "PX ";
Dialogwidth = (parseint (layout. offsetwidth) + 10) + "PX ";
}
// -->
</SCRIPT>
Note: layout in the above Code is the ID of a table in the body. All controls on the page are contained in this table and their width and height attributes are not set.
So I used it in my own Program Application in, because I recently made a task to automatically generate queries, input, and modify interfaces based on the data dictionary, it is very useful. After opening the window to dynamically generate the interface, you can set the size of a window in an adaptive manner, so you do not have to worry about opening a window as much as possible.
However, it is still found that the modal window cannot be centered after its size is changed automatically, and dbnetgrid cannot be centered automatically, I thought it was impossible to automatically center. But today, I was inspired by the sudden increase, so I modified the Code as follows:
<Script language = "JavaScript">
<! --
Window. setTimeout (sizedialog, 1 );
Function sizedialog ()
{
Dialogheight = (parseint (layout. offsetheight) + 30) + "PX ";
Dialogwidth = (parseint (layout. offsetwidth) + 10) + "PX ";
Window. setTimeout (centerdialog, 1 );
}
Function centerdialog ()
{
VaR topposition = (screen. Height )? (Screen. Height-parseint (dialogheight)/2: 0;
VaR leftposition = (screen. width )? (Screen. Width-parseint (dialogwidth)/2: 0;
Dialogtop = topposition;
Dialogleft = leftposition;
}
// -->
</SCRIPT>
When running, everything is OK. The window opened can not only change its size according to its own content, but also be centered after the change. (My memory is not good, so I want to record it here and also provide a method for my friends)
Demo: http://www.openlab.com.cn /~ COMY/mp.htm