Js experience 2

Source: Internet
Author: User
1. The complete name of the text box in the form should be: Invalid variable Doc ument. myform. text1, where window can be omitted. Therefore, we wrote document. myform. text1 before. 1) The window object represents the entire browser window and is the top-level root. 2) include historical history objects (store historical information, which can be

1. The complete name of the text box in the form should be: Invalid variable Doc ument. myform. text1, where window can be omitted. Therefore, we wrote document. myform. text1 before. 1) The window object represents the entire browser window and is the top-level root. 2) include historical history objects (store historical information, which can be

1. The complete name of the text box in the form should be:

Invalid argument Doc ument. myform. text1, where the window can be omitted, So we wrote as follows:

Document. myform. text1 is like this.

1) The window object represents the entire browser window and is the top-level root.

2) include historical history objects (stores historical information and can forward and backward ),

2. Window object:

Name

Description

Document

Indicates the HTML document in the given browser window.

History

Contains information about the URLs visited by the customer.

Location

Contains information about the current URL.

Name

Set or retrieve the name of the window or framework.

Status

Set or retrieve messages in the status bar at the bottom of the window.

Screen

Contains information about the client's screen and display performance.

Method:

Name

Description

Alert ("m prompt information ")

A dialog box containing messages is displayed.

Confirm ("prompt message ")

A confirmation dialog box is displayed, which contains a confirmation cancel button.

Prompt ("prompt message")

Pop-up prompt box

Open ("url", "name ")

Open a new window with the specified name and load the document specified by the specified URL. If no URL is provided, open a blank document.

Close ()

Close current window

SetTimeout ("function", in milliseconds)

Set the timer: execute a function after a specified millisecond Value

ClearTimeout (timer object)

Cancel setTimeout settings

The confirm dialog box is displayed. Click OK to return true. If yes, false is returned.

3.Open ("open window url", "window name", "window feature ")

The window features are as follows and can be combined as needed:

Height: The window height;

Width: The window width;

Top: The pixel value between the window and the top of the screen;

Left: The pixel value between the window and the left of the screen;

Toolbar: whether to display the toolbar. yes indicates display;

Menubar and scrollbars indicate the menu bar and scroll bar.

Resizable: whether to change the window size. yes or 1 indicates yes.

Location: whether to display the address bar. yes or 1 is allowed.

Status: whether to display information in the status bar. yes or 1 indicates yes;

4. full screen display window:

Screen. availWidth --- screen width (except Windows taskbar)

Screen. availHeight --- screen height (except Windows taskbar ).

For example:

Also available: screen. width --- display screen width

Screen. height --- display the screen height

? 5. The window object provides two methods to implement the Timer:

-Window. setTimeout (expression [expression], delay time [n]), executed every N seconds!

-Window. setInterval (expression [expression], delay time [n]): Execute once in N seconds, loop!

Note: expression can be a code enclosed in quotation marks or a function name (a function without any parameters ):

SetTimeout ("move ()", 1000); or setTimeout (move, 1000 );

? How to cancel the Timer:

-Cancel setTimeout: window. clearTimeout (id );

-Cancel setInterval: window. clearInterval (id );

6.Screen Object

? The Screen Object is automatically generated when JavaScript is run.

? Common Properties of screen objects

-Height: returns the screen height.

-Width: return the screen width of the monitor.

-AvailHeight: return the height of the display screen (except for the Windows taskbar ).

-AvailWidth: return the width of the display screen (except for the Windows taskbar ).

-ColorDepth: returns the bit depth of the color palette on the target device or buffer (the number of digits used for color in each pixel, with a value of, 32 ).

? Visible area width of the webpage: document. body. clientWidth

? Visible area height: document. body. clientHeight

? Visible area width of the webpage: document. body. offsetWidth (including the width of the edge)

? Visible area height of the webpage: document. body. offsetHeight (including the width of the edge)

? Webpage text width: document. body. scrollWidth

? Webpage text height: document. body. scrollHeight

? The height of the page to be rolled: document. body. scrollTop

? Left: document. body. scrollLeft

? Page body: window. screenTop

? Page body part left: window. screenLeft

? Screen Resolution height: window. screen. height

? Screen Resolution width: window. screen. width

? Available screen workspace Height: window. screen. availHeight

? Available workspace width: window. screen. availWidth

? Process address bar information: location object

-The Location object is a sub-object of the wodow object. It contains the webpage address of the window object, that is, the URL. For example:

? Window. location = http://www.sohu.com; // jump to page

? Window. loaction. href = http://www.sohu.com; // same as above

? Window. location. reload (); // refresh the page

? Window. location. replace (url); // use the url to refresh the current webpage

-Use three methods to change the website of the current webpage:

Method 1: window. open ()

Method 2:
Location. href

Method 3: location. replace ()

7. Location Object Attributes

Name

Description

Host

Set or retrieve the host name and port number of the location or URL

Hostname

Set or retrieve the Host Name of a location or URL

Href

Set or retrieve complete URL strings

Method:

Name

Description

Assign ("url ")

Load the new HTML document specified by the URL.

Reload ()

Reload the current page

Replace ("url ")

Replace the current document by loading the document specified by the URL

8. history Object

?A history object is a subobject under a window object. It is actually an object array that contains a series of url addresses accessed by users. It is used for the forward and backward buttons in the toolbar of the browser.

?Common attributes and Methods

-History. length: Number of historical objects

-History. back (); displays the web page of the previous web site in the browser history list.

-History. go (n) or history. go (web site): displays the web page of the n web site in the history List of the browser, n> 0 forward n <0 back

-History. forward (); // display the web page of a previous website in the browser history list

9. Document Object

?Document objects are a major part of window objects. They contain all element objects displayed on webpages.

-Document. write (str); // output a row

-Document. writeln (str); // output a row and press ENTER

Attribute:

Name

Description

AlinkColor

Set or retrieve the color of all activity links in the document

BgColor

Set or retrieve the background color of the Document Object

Body

Specify the start and end of the document body

LinkColor

Set or retrieve the document link color

Location

Contains information about the current URL

Title

Contains the document title

Url

Set or retrieve the URL of the current document

VlinkColor

Set or retrieve the color of the link accessed by the user

Common Methods:

Name

Description

Clear ()

Clear current document

Close ()

Disable the output stream and forcibly display the sent data

Write ("text ")

Write text to documents

This section focuses on:

?JavaScript is an event-driven program.

?OnFocus obtains the focus event, indicating that the cursor is obtained, and the onBlur loses the focus event, which is the opposite.

?The browser object is a hierarchical structure, and the window is the top-level root object.

?Use the open () method of the window object to open a window

?Set the timer and use the setTimeout () method of the window object.

?The back () and forward () Methods of the location object are equivalent to the forward and backward buttons.

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.