JS controls browser size

Source: Internet
Author: User
When designing a webpage, you may often encounter poor window control, especially for large screens and wide screens. Excessive stretching leads to severe page deformation. It is really not beautiful. If CSS is well written, you can avoid these problems, but sometimes it is just a simple small page, such as writing a claim or something yourself, the whole screen is too embarrassing ...... CSS makes it easy to use. The simple page still has a fixed size. Just list the two items as needed. Below we will introduce several methods for controlling the browser window size using JS:

JS controls the browser window sizeCodeOne:Program code <SCRIPT>
Window. moveTo (0, 0); // move the window
Window. resizeTo (800,600); // change the size
Window. onresize = new function ("window. resizeTo (800,600 );")
</SCRIPT>

JS controls the size of the browser window Code 2:Program code <SCRIPT>
If (window! = Top) top. Location. href = location. href;
Self. resizeTo (800,600 );
</SCRIPT>

JS controls the size of the browser window code 3:Program code <script language = "JavaScript">
Function openwin ()
{
VaR I = 0;
I = open ("", "", "width = 500, Height = 500 ");
}
</SCRIPT>

JS controls the size of the browser window code 4:Program code <script language = JavaScript>
<! --
VaR new_width = 800; // the browser width you want to fix
VaR new_height = 600; // The height of the browser you want to fix
Function resizewindow ()
{
Window. resizeTo (new_width, new_height );
}
Resizewindow ();
// -->
</SCRIPT>

......
This JS control is too much, and there will be a lot of JS introduction at any time. It is enough to leave these few. Of course, it is best to use CSS. Here we recommend that you only use it in a hurry and learn CSS thoroughly. These are all minor dishes.

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.