JavaScript Learning Notes (10) _javascript Tips

Source: Internet
Author: User
Window object
The Window object represents the entire browser window, and Windows can also be used to move or resize the browser it represents.

One, window operation
Window.moveby (Dx,dy)

Moves the dx pixel horizontally in the browser window relative to the current position, moving dy pixels vertically. DX value is negative, move window left, dy value is negative, move window up.

Window.moveto (X,y)

Move the browser window so that its upper-left corner is located at the user's screen (x,y). You can use negative numbers, but this will remove some of the windows from the viewable area of the screen.

Window.resizeby (DW,DH)
Relative to the current size of the browser window, the width of its mouth is adjusted to the DW pixel, the height of dy pixel. DW is negative, reduce the width of the window, dy for negative numbers, reduce the height of the window.
Window.resizeto (W,H)
Adjust the width of the window to W and height to H. Negative numbers cannot be used. The position of the window on the screen and its size. Because of the lack of corresponding standards, the problem arises.

Ii. Navigating and opening new windows
window.open () method opens a new window

The method receives four parameters: ① the name of the Url② new window that loads the new window (used for the target) ③ attribute string ④ describes whether to replace the Boolean value of the currently loaded page with the newly loaded page.

List of settings for the third parameter attribute string:

Set up

Value

Description

Left

Number

The left coordinate of the newly created window, not a negative number *

Top

Number

Describes the upper coordinates of the newly created window. cannot be a negative number *

Height

Number

Sets the height of the newly created window. This number cannot be less than 100 *

Width

Number

Sets the width of the newly created window. This number cannot be less than 100 *

Resizable

Yes,no

To determine whether a new window can drag the edge resize, and the default value is no

Scrollable

Yes,no

Determines whether the new window allows scrolling, and the default value is no

Toolbar

Yes,no

Determines whether a new window displays a toolbar, and the default value is no

Status

Yes,no

Determines whether the new window displays the status bar, and the default is no

Location

Yes,no

Determines whether the new window displays the address bar, and the default value is no

Note: attribute strings are separated by commas, so there can be no spaces before or after a comma or equal sign.

The window.open () method returns the Window object as its function value, which is the newly created window (the frame if the given name is an existing frame name). With this object, you can manipulate the newly created window.

Third, System dialog box

This will not have to write more. Alert (), confirm (), prompt ()

Four, status bar

The status bar tells the user when to load the page and when to complete the load page, which can be controlled by the window's two properties: status and Defaultstatus

Defaultstatus is used to define the default display for the browser status bar, but when the mouse is moved to the link, the text of the status bar changes, and the move out of the link changes to the Defaultstatus defined value. This differs from the Status property to temporarily change the status bar content.

V. Time intervals and pauses

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 executing it.

To suspend cancellation, call the Cleartimeout () method, which receives a parameter "number pause ID", which is created by settimeout (). SetTimeout () returns a numeric pause ID similar to the process ID in the operating system. The pause ID is essentially the ID of the process to delay.

Vi. history

The Go () method has only one parameter, that is, the number of pages that are forward or backward. If it's negative, go back in the browser history, and if it's an integer, go ahead.

Window.history.go (-1); Back one page

Window.history.go (1); Forward one page

Or

History.go (-1); A reference to a Window object is not required

The same can be done with the back () method and the Forward () method:

History.back (); Back one page

History.forward (); Forward one page

To view the number of pages in history with the length property:

alert (history.length);

If you want to move forward or back multiple pages, you can use the Length property to see if you can do this 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.