Unit04:bom Overview, Window object, window common sub-object-1

Source: Internet
Author: User

Review:

1. Form object:

How to find: document.forms[serial number |name]

How to find the elements of data acquisition:

document.forms[ordinal |name].elements[serial number |name]

To get or lose focus on an element: Elem.focus ()

Elem.blur ()

Get/Lose Focus event: onfocus onblur

Get the element that is currently getting focus: document.activeelement

Event: OnSubmit is automatically triggered before the form is formally submitted

Perform validation on the entire form

Form.onsubmit=function () {

As long as any one of the validations does not pass,

just * Cancel Event *: 2 steps:

1. Get the Event object e:

var e=window.event| | Arguments[0];

if (E.preventdefault) {

E.preventdefault ()//dom

}else{

E.returnvalue=false//IE8

}

Form submission: 2 kinds:

-Direct Click on the Submit button;

-If any element in the current form receives focus, it can be automatically submitted by pressing ENTER;

As long as the automatic form submission, the onsubmit will be triggered first, can be verified

"BOM"

BOM: The object that operates the browser window;

1.window objects: 2 characters;

-Acts as a global object;

-Superiors of all BOM objects;

Properties: (can only be obtained, cannot be set)

-Innerheight; height of document display area

-Innerwidth;

-Outerheight; window height;

-Outerwidth

-pageYOffset; The distance from the upper-left corner of the document to the upper-left corner of the document display;

-Pagexoffset;

Open Connection: 4 species;

-Open a new connection in the current window and back up;

Html:target= "_self";

Js:[window.] Open ("url", "_self")

-Open a new connection in the current window, prohibit backward;

Js:location.replace ("New url");

-Opens in new window, can be opened repeatedly

Html:target= "_blank";

Js:[window.] Open ("url", "_blank")

-Open in New window, cannot be opened repeatedly

Target--> the name of the target window

_self: Automatically get the current window name

_blank: Create a new window, randomly generate a duplicate name

* Window name: The same window name in memory can only open one, after open, will replace the first open;

html:target= "Custom window name";

Js:[window.] Open ("url", "Custom window name");

2. Window size and positioning:

Size:

1. Window.innerheight/width: Document display area width height

Outerheight/width: Width of the entire window

2. Screen.height/width: Desktop full resolution width high

Screen.availheight/availwidth: Remove the width of the remaining resolution after the taskbar

3. Sizing: Window.resizeto (width,height)

Adjusted to

Resizeby (variable width, height of change)

Position:

1. Upper left corner x coordinate: window.screenleft| | Window.screenx;

Y coordinate: window.screentop| | Window.screeny;

2. Move the window to the specified coordinates: window.moveto (x, y)

3. When an event occurs, the mouse is relative to the entire screen's coordinates:

Event.screenx|screeny

3. Timer: Animation; * * * [4_1.html]

Timer: Allow the browser to perform the same task repeatedly at specified intervals

2 Kinds:

Recurring timer: Lets the browser perform the same task repeatedly at a specified time interval, and executes repeatedly if not manually stopped

Disposable Timer: Let the browser wait for a period of time, perform a task, and automatically stop.

At the end of the one-time timer, reboot a disposable timer

Recommendation: Try to use one-time timers instead of periodic timers

How to use: Periodic and disposable usage exactly the same

Periodicity: 3 things:

1. The task to be performed for each step of the animation (function object)

function Step () {

What to do every step of the way

}

2. Put one-step task into the timer and call repeatedly

Timer=setinterval (step, interval of milliseconds)

3. You must use global variables to temporarily store the timer's number

Clearinterval (timer)

Disposable: 3 Things

1. The task to be performed for each step of the animation (function object)

function Step () {

What to do every step of the way

/* Determine if it is necessary to continue to start the next timer according to the conditions */}

2. Put one-step task into the timer and call repeatedly

Timer=settimeout (step, interval milliseconds | Number of milliseconds to wait)

3. You must use global variables to temporarily store the timer's number

Cleartimeout (timer)

Stop the timer that is waiting

Unit04:bom Overview, Window object, window common sub-object-1

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.