JS solution that automatically adjusts pop-up window size based on content

Source: Internet
Author: User
Tags eval window
js| pop-up window | solve

Problem
When the creation of pain, according to the contents of the window to automatically adjust the size of the window, if the screen is equal to the size of the scroll bar appears.
Solution
Add a JS script method to the pop-up page Win_onload (), in the body of the OnLoad method to refer to Win_onload (), add a table in the body, the table ID named Tbllist, The size of the window is the size of the table plus 50 on the width and height.

Some of the code is as follows:

<script language=javascript>
Function win_onload () {
var width = document.all[ Tblkslist "].offsetwidth;    
var height = document.all[" Tblkslist "].offsetheight; 
 
Width = eval (width + 50);
Height = eval (height + 50);
 
if (width <)
Width = 500;
Else if (Width > screen.width)
width = screen.width;
 
if (height <)
Height = 400;
Else if (height > screen.height)
height = screen.height;
 
//alert (width); alert (height);
Window.resizeto (width,height);
}
</script>

<body bgcolor= "0099CC" leftmargin= "0" topmargin= "0" marginwidth= "0" marginheight= "0" >

<table width= "border=" 0 "cellpadding=" 0 "cellspacing=" 0 "class=" table-left1-right2 "style=" border:1 Solid 000000 "id=" Tbllist ">
<TR>
<TD width= "100%" valign= "Top" colspan=2>
Welcome to use!
</TD>
</TR>
</TABLE>
</BODY>



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.