# Note #javascript Advanced Article One

Source: Internet
Author: User

#javascript Advanced Article

Http://www.imooc.com/learn/10

# know Dom

#window Object

  

browser window visual area monitoring--

in different browsers (PCS) are practical JavaScript Scenarios:

var w= document.documentElement.clientWidth | | Document.body.clientWidth;

var h= document.documentElement.clientHeight | | Document.body.clientHeight;

Web content Size Monitoring --

Browser compatibility

var w=document.documentelement.scrollwidth | | document.body.scrollWidth;

var h=document.documentelement.scrollheight | | document.body.scrollHeight;

# Common Function Object Properties Introduction 1

Date Common Object--

History Object--

The history object records the pages (URLs) that the user has browsed, and enables the browser to move forward and backward with similar navigation capabilities.

Note : Starting from the moment the window is opened, each browser window, every tab, and even each frame has its own history object with a specific window Object Association.

Syntax: window.history. [ properties | method ]

Note: window can be omitted.

Location Object--

Location is used to get or set the URL of the form and can be used to resolve URLs.

Grammar : location. [ Properties | Method]

Navigator Object--

The Navigator object contains information about the browser and is typically used to detect the version of the browser and operating system.

Object Properties :

Screen Object--

The screen object is used to get the user's onscreen information.

syntax:window.screen. Properties

1. Screen.height Returns the high screen resolution

2. Screen.width Returns the width of the screen resolution

Note :

1. Units are measured in pixels.

2. The Window.screen object can be written without using the window prefix

Object Properties :

* Height: The altitude of the entire screen viewable area; availheight: minus the operating system footprint (the overall height of the browser)

The Slice () method returns the selected element from an existing array [returns a new sub-array].

Syntax: Arrayobject.slice (start,end)

Attention:

0. returns a new array containing the elements from start to end (excluding the element) in the Arrayobject .

1. Negative values can be used to select elements from the tail of the array.

2. If end is not specified, then the Slice () method selects all elements from start to the end of the array.

3. String.slice () is similar to Array.slice () .

The sort () method causes the elements in the array to be arranged in a certain order.

Syntax: Arrayobject.sort ( method function)

Note :

1. If the < method function is not specified , it is sorted in Unicode code order.

2. If you specify the < method function , then sort by the < method function > The sorting method specified.

3.< method function > To compare two values, and then return a number that describes the relative order of the two values. The return value is as follows (the comparison function should have two parameters A and b ):

A return value of <=-1 indicates that A appears before B in the sorted sequence .

If the return value >-1 && <1, then A and B have the same sort order.

A return value of >=1 indicates that A appears after B in the sorted sequence .

And, by number :

<script type= "Text/javascript" >  function Sortnum (  A, a) {return a-B;//ascending, such as descending, "A-a" should be "B-a"} var Myar R = new Array ("n", "+", "a", "6", "+", "1");  document.write (Myarr + "<br>");  document.write (Myarr.sort (sortnum));</script>

# Note #javascript Advanced Article One

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.