JS Experience 2__js

Source: Internet
Author: User
Tags setinterval

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

WINDOW.DOCUMENT.MYFORM.TEXT1, where window can be omitted, so we write earlier as:

That's how Document.myform.text1 came in.

1 Window object represents the entire browser window and is the topmost root.

2) down to include the history historical objects (storing historical information, can forward backward function),

2.Window objects:

name

Description

Document

Represents an HTML document in a given browser window.

History

Contains information about the URLs that the customer has visited.

Location

Contains information about the current URL.

Name

Sets or retrieves the name of a window or frame.

Status

Sets or retrieves the message 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 Info")

Displays the dialog box that contains the message.

Confirm ("Hint info")

Displays a confirmation dialog box that contains a OK Cancel button

Prompt ("hint info")

Pop-up message box

Open ("url", "name")

Opens a new window with the specified name and loads the document specified by the given URL, or opens a blank document if no URL is provided

Close ()

Close the current window

SetTimeout ("function", number of milliseconds)

Set Timer: Performs a function after a specified millisecond value

Cleartimeout (Timer object)

Cancel settimeout Settings

Confirm Pop-up Confirmation dialog box, click OK to return True, cancel return False

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

 

The features of the window are as follows, and can be any combination:

Height: Window heights;

Width: Window breadth;

Top: The pixel value of the window from above the screen;

Left: The pixel value of the window from the left-hand side of the screen;

Toolbar: Show toolbar, yes for display;

Menubar,scrollbars represents the menu bar and scroll bar.

Resizable: Allow window size to be changed, yes or 1 to allow

Location: Whether the address bar is displayed, yes or 1 is allowed

Status: Whether the information in the status bar is displayed, yes or 1 is allowed;

4. Full Screen display window:

Screen.availwidth---screen width (other than the Windows taskbar)

Screen.availheight---The height of the screen (other than the Windows taskbar).

For example:

Also available: screen.width---The width of the display screen

Screen.height---Display the height of the screen

The 5.window object provides two ways to implement the timer:

–window. settimeout (expression [expression], delay time [n]), executed once every n seconds.

–window. SetInterval (expression [expression], delay time [n]), execute once in n seconds, loop.

Note: expression can be code enclosed in quotes, or it can be a function name (a function with no arguments):

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

• Screen objects are automatically generated by JavaScript runtime objects

• Common Properties for screen objects

–height: Returns the height of the display screen.

–width: Returns the width of the monitor screen.

–availheight: Returns the height of the display screen (other than the Windows taskbar).

–availwidth: Returns the width of the display screen (other than the Windows taskbar).

–colordepth: Returns the bit depth of the palette on the target device or buffer (the number of bits per pixel used for the color, with a value of 1,4,8,15,16,24,32).

• Web page visible area wide: document.body.clientWidth

• Web page Visible Area High: document.body.clientHeight

• Web page visible area wide: document.body.offsetWidth (including edge width)

• Web page Visible Area High: document.body.offsetHeight (including edge width)

* Full text of the Web page: document.body.scrollWidth

* The full text of the Web page High: document.body.scrollHeight

• Web pages are rolled up high: Document.body.scrollTop

• Pages are rolled away to the left: Document.body.scrollLeft

• Web page body part: Window.screentop

* Page body part left: Window.screenleft

• High screen resolution: Window.screen.height

• Screen resolution width: window.screen.width

• Screen available workspace height: window.screen.availHeight

• Screen available workspace width: window.screen.availWidth

• Processing Address bar information: Location objects

The –location object is a child object of the Wodow object that contains the page address content of the Window object, which is the URL. For example:

window.location= "http://www.sohu.com";//Jump to page

window.loaction.href= "http://www.sohu.com";/ibid.

window.location.reload ()//Refresh Page

window.location.replace (URL);//refresh current page with URL

– Change the Web site of the current Web page in three ways:

methods 1:<a href= "Javascript:window.open (' http://www.yahoo.com ', ' _self ')" >window.open () </a>

Methods 2:<a href= "javascript:location.href= ' http://www.yahoo.com '" >
Location.href </a>

method 3:<a href= "Javascript:location.replace (' http://www.yahoo.com ')" > Location.replace () </a>

7.Location Object Properties

name

Description

Host

Sets or retrieves the host name and port number of a location or URL

hostname

Sets or retrieves the host name portion of a location or URL

Href

Sets or retrieves the complete URL string

Method:

name

Description

assign ("url")

loads the new HTML document specified by the URL.

Reload ()

Reload Current Page

replace ("url")

replaces the current document by loading the document specified by the URL

8. Historical records (History) objects

• The History object is a child object under the Window object. It is actually an array of objects that contains a series of user-visited URL addresses for the forward and Back buttons in the browser toolbar.

Common Properties and methods

history.length: Number of historical objects

History.back () displays a page in the browser history list that is back to one URL

history.go (n) or History.go (URL): The page showing the nth URL in the history list of the browser, n>0 forward n<0 back

History.forward ()///Displays the Web page of a Web site in the browser history list

9.Document Objects

• The Document object is a major part of the Window object that contains the individual element objects that the Web page displays.

document.write (str);//Output line

Document.writeln (str);//output line, and enter

Properties:

name

Description

Alinkcolor

Sets or retrieves the color of all active links in a document

bgcolor

Sets or retrieves the background color of a Document object

Body

Specify the beginning and end of the body of the document

LinkColor

set or retrieve the color of a document link

location

contains information about the current URL

title

include title of document

URL

Sets or retrieves the URL of the current document

Vlinkcolor

Sets or retrieves the color of links that users have visited

Common methods:

name

Description

Clear ()

clear the current document

Close ()

closes the output stream and forces the display of the sent data

Write ("text")

writing text to a document

This section focuses on:

JavaScript programs are event drivers

onfocus Gets the focus event, indicating that the mouse cursor is obtained, onblur loses focus events, just as opposed to

Browser object is a layered structure, window is the top-level root object

open windows using the open () method of the Window object

set timer, using 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.