JavaScript Advanced Learning 6 Browser objects

Source: Internet
Author: User

Window Object : Is the core of the BOM, and the Window object refers to the current browser window. 、

Window object Method

  

JavaScript timers: in JavaScript, we can execute code after a set interval of time, not immediately after a function is called.
Timer type : one -time timer: Fires only once after a specified delay.
interval Trigger timer: Fires once every time interval is specified.
Timer Method :

            timer setinterval () : At execution time, Executes code every specified time after the page is loaded.
                                    Syntax :   setinterval (Code, interaction time);
                            parameter description: 1. Code: The function to be called or to be The code string for the line.

                                              2. Interaction time: The time interval between periodic execution or invocation of an expression, in milliseconds (1s=1000ms).
                                return value :     A value that can be passed to clearinterval () to suppress periodic execution of "code."
                              call function Type (assuming a clock () function):
                                                   setinterval ("clock ()", "&nbs") P          setinterval (clock,1000)            

          Cancel Timer cleartimeout () : SetTimeout ( ) is used with cleartimeout () to stop the timer.
                                              syntax :   cleartimeout (id_of_settimeout)
    &N Bsp                                   parameter Description :    id_of_settimeout: The ID value returned by setTimeout (). This value identifies the deferred execution code block to be canceled.

History Object: It records the page (URL) that the user has browsed, and can realize the function of browser forward and backward similar navigation.
Note : Starting from the moment the window is opened, each browser window, every tab, and even each frame has its own history object associated with a particular window object.
Syntax: Window.history.         [Properties | method] Note : Window can be omitted.

      returns the previous browsed page back () method : Loads the previous URL in the History list.
                                                    syntax  :window.history.back ();      //Return to the previous browse page, the code is as follows: Window.history.back ();
                                                    note  : equivalent to clicking on the browser's rewind button .  back () equivalent to go ( -1)

return to the next Browse page forward () method : Loads the next URL in the history list. If you want to go back to the page you browsed before going backwards, you can use the forward () method, which is the following code:
Window.history.forward ();
Note : Equivalent click forward button. Forward () equivalent to go (1)

Go back to other pages in browsing history Go () method : Loads a specific page in the historical list based on the current page.
Syntax : window.history.go (number);

Location object: used to get or set the URL of the form and can be used to resolve the URL.
Syntax: location. [Properties | method]
Location Object Properties Diagram:

Location Object properties:

Location Object method:

Navigator Object : Contains information about the browser, typically used to detect the version of the browser and the operating system.
Object properties:

useragent : Returns a string representation of the user-agent header (that is, a string that includes browser version information, etc.)
Syntax:navigator.useragent
Several browsing user_agent., like 360 compatibility mode with IE, speed mode with the Chrom kernel.

Screen object: used to get the user's screen information.
Syntax: Window.screen. Properties
Object properties:

High and wide screen resolution:The Window.screen object contains information about the user's screen.
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.

screen available high and wide
1. The Screen.availwidth property returns the width of the visitor's screen, in pixels, minus interface features such as the taskbar.
2. The Screen.availheight property returns the height of the visitor's screen, in pixels, minus interface features such as the taskbar.
Note: The taskbar's default height is different from the system, and the taskbar position can be anywhere up or down the screen, so it is possible that the width and height are not the same.

JavaScript Advanced Learning 6 Browser objects

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.