JavaScript Study Notes (10)

Source: Internet
Author: User

Window object
The window object indicates the entire browser window. The window can also be used to move or adjust the size of the browser it represents.

I. window operations
Window. moveBy (dx, dy)

Move the browser window horizontally to dx pixels and vertically to dy pixels relative to the current position. The dx value is negative, and the window is moved to the left. The dy value is negative, and the window is moved up.

Window. moveTo (x, y)

Move the browser window so that the upper left corner of the window is located at (x, y) of the user screen. You can use a negative number, but this will remove some windows from the visible area of the screen.

Window. resizeBy (dw, dh)
In contrast to the current size of the browser window, adjust the width of its port to dw pixels and the height to dy pixels. Dw is a negative number, narrowing down the window width, dy is a negative number, narrowing the window height.
Window. resizeTo (w, h)
Adjust the window width to w and the height to h. Negative numbers cannot be used. The position and size of the window on the screen. Due to the lack of relevant standards, the problem arises.

2. Navigation and opening a new window
Window. open () method to open a new window

This method receives four parameters: ① loading the URL of the new window ② name of the new window (used by the target) ③ feature string ④ indicates whether to replace the Boolean value of the currently loaded page with the newly loaded page.

The third parameter feature string settings list:

Set

Value

Description

Left

Number

The left coordinate of the newly created window. It cannot be a negative number *

Top

Number

Indicates the upper coordinates of the newly created window. Cannot be negative *

Height

Number

Set the height of the newly created window. The number cannot be less than 100 *

Width

Number

Set the width of the newly created window. The number cannot be less than 100 *

Resizable

Yes, no

Determines whether the edge of a new window can be dragged to adjust the size. The default value is no.

Scrollable

Yes, no

Determines whether the new window can be rolled. The default value is no.

Toolbar

Yes, no

Determines whether the toolbar is displayed in the new window. The default value is no.

Status

Yes, no

Determines whether the status bar is displayed in the new window. The default value is no.

Location

Yes, no

Determines whether the address bar is displayed in the new window. The default value is no.

Note: feature strings are separated by commas (,). Therefore, there must be no space before or after a comma or equal sign.

The window. open () method returns the window object as its function value. The window object is the newly created window (if the given name is the existing framework name, it is the framework ). With this object, you can operate on the newly created window.

3. System dialog box

You don't need to write more. Alert (), confirm (), prompt ()

 

Iv. Status Bar

The status bar tells you when to load the page and when to load the page. You can control the status and defaultStatus through the two properties of window.

DefaultStatus is used to define the default display content of the browser status bar. However, when you move the cursor over the link, the text of the status bar changes and the value of defaultStatus is changed when you move the cursor over the link. This is different from the status attribute for temporarily changing the content of the status bar.

 

5. interval and pause

SetTimeout () receives two parameters. The first parameter can be a code string or a function pointer, and the second parameter is the number of milliseconds (1/1000 seconds) to wait before execution ).

To suspend cancellation, call the clearTimeout () method. This method receives a parameter "Digital pause ID", which is created by setTimeout. SetTimeout () returns a digital pause ID, similar to the process ID in the operating system. The pause ID is essentially the ID of the process to be delayed.

Vi. History

The go () method has only one parameter, that is, the number of forward or backward pages. If it is a negative number, it will go back in the browser history. If it is an integer, it will go forward.

Window. history. go (-1); // return a page

Window. history. go (1); // a previous page

Or

History. go (-1); // the reference of the window object is not required.

The back () method and forward () method can be used to perform the same operation:

History. back (); // returns a page

History. forward (); // Previous Page

View the number of pages in the history using the length attribute:

Alert (history. length );

If you want to forward or backward multiple pages, you can use the length attribute to see if this can be done first.

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.