Home > Web Front-end > JS Tutorial > body text

Usage of BOM objects in Javascript

不言
Release: 2018-08-01 16:42:51
Original
1332 people have browsed it

This article introduces you to the usage of BOM objects in Javascript. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Window
Customize the nature of all variables
Any global variable function object we define will become an attribute of the window object

Built-in global variables and Method

Global constants: Infinity, NaN, undefined, null
Global methods: eval(), isFinite(),
isNaN(), parseFloat(), parseInt(),decodeURI(),decodeURIComponent(),
encodeURI(), encodeURIComponent()

Window common methods

Open
Close
Copy after login

Location object

1. Attribute

hash Sets or returns the URL starting with the pound sign (#) (anchor)
host Sets or returns the host name and port number of the current URL
hostname Sets or returns the host name of the current URL
href Sets or returns the complete URL
pathname Sets or returns the path part of the current URL
port Sets or returns the port number of the current URL
protocol Sets or returns the protocol of the current URL
**search Sets or returns the URL starting from the question mark (?) (query part) ** Used to obtain the query string ( For example: window.location.search)

2. Method

assign()

Load a new document, this The effect is the same as directly assigning a URL to the href attribute of the Location object

reload()

Reload the current document
If the method does not specify parameters, or parameters If false, it will use the HTTP header If-Modified-Since to detect whether the document on the server has changed. If the document has changed, reload() will download the document again.
If the document has not changed, this method will load the document from the cache.
This is exactly the same as the effect of the user clicking the browser's refresh button.
If the parameter of this method is set to true, then regardless of the last modification date of the document, it will bypass the cache and re-download the document from the server. This has the exact same effect as if the user held down the Shift key while clicking the browser's refresh button.

replace()

Replace the current document with a new document. The replace() method will not generate a new record in the History object.
When this method is used, the new URL will overwrite the current record in the History object.

History
History

Common methods and properties For example: window.history.forward()

go(-1)
Return to the previous page

.back()
Back

.forward()
Forward

Navigator

Common methods and properties
appCodeName browser code name
appName browser name
ppVersion browser version number
userAgent browser name and version number
platform browser platform
Win32 ", "Win16", "WinCE", "Mac68k", "MacPPC", "HP-UX", "SunOS", etc.
cpuClass CPU information "x86"
online Whether the browser is online
cookieEnabled Is cookie available?

Error

常用方法和属性
try {
alert(‘’)
}
catch(e) {
e.message
}
Copy after login

Recommended related articles:

The call() method and apply() method in Javascript What are the usages? (Code attached)

A brief explanation of function scope and block-level scope in JavaScript

The above is the detailed content of Usage of BOM objects in Javascript. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!