Home Web Front-end JS Tutorial Usage of BOM objects in Javascript

Usage of BOM objects in Javascript

Aug 01, 2018 pm 04:42 PM
javascript Object-Oriented Programming object-oriented design patterns

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP MVC Architecture: Building Web Applications for the Future PHP MVC Architecture: Building Web Applications for the Future Mar 03, 2024 am 09:01 AM

Introduction In today's rapidly evolving digital world, it is crucial to build robust, flexible and maintainable WEB applications. The PHPmvc architecture provides an ideal solution to achieve this goal. MVC (Model-View-Controller) is a widely used design pattern that separates various aspects of an application into independent components. The foundation of MVC architecture The core principle of MVC architecture is separation of concerns: Model: encapsulates the data and business logic of the application. View: Responsible for presenting data and handling user interaction. Controller: Coordinates the interaction between models and views, manages user requests and business logic. PHPMVC Architecture The phpMVC architecture follows the traditional MVC pattern, but also introduces language-specific features. The following is PHPMVC

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

'PHP Object-Oriented Programming Design Patterns: Understanding SOLID Principles and Their Applications' 'PHP Object-Oriented Programming Design Patterns: Understanding SOLID Principles and Their Applications' Feb 25, 2024 pm 09:20 PM

SOLID principles are a set of guiding principles in object-oriented programming design patterns that aim to improve the quality and maintainability of software design. Proposed by Robert C. Martin, SOLID principles include: Single Responsibility Principle (SRP): A class should be responsible for only one task, and this task should be encapsulated in the class. This can improve the maintainability and reusability of the class. classUser{private$id;private$name;private$email;publicfunction__construct($id,$nam

PHP extension development: How to design custom functions to support object-oriented programming? PHP extension development: How to design custom functions to support object-oriented programming? Jun 01, 2024 pm 03:40 PM

PHP extensions can support object-oriented programming by designing custom functions to create objects, access properties, and call methods. First create a custom function to instantiate the object, and then define functions that get properties and call methods. In actual combat, we can customize the function to create a MyClass object, obtain its my_property attribute, and call its my_method method.

How to get HTTP status code in JavaScript the easy way How to get HTTP status code in JavaScript the easy way Jan 05, 2024 pm 01:37 PM

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

Application of golang functions in high concurrency scenarios in object-oriented programming Application of golang functions in high concurrency scenarios in object-oriented programming Apr 30, 2024 pm 01:33 PM

In high-concurrency scenarios of object-oriented programming, functions are widely used in the Go language: Functions as methods: Functions can be attached to structures to implement object-oriented programming, conveniently operating structure data and providing specific functions. Functions as concurrent execution bodies: Functions can be used as goroutine execution bodies to implement concurrent task execution and improve program efficiency. Function as callback: Functions can be passed as parameters to other functions and be called when specific events or operations occur, providing a flexible callback mechanism.

'Introduction to Object-Oriented Programming in PHP: From Concept to Practice' 'Introduction to Object-Oriented Programming in PHP: From Concept to Practice' Feb 25, 2024 pm 09:04 PM

What is object-oriented programming? Object-oriented programming (OOP) is a programming paradigm that abstracts real-world entities into classes and uses objects to represent these entities. Classes define the properties and behavior of objects, and objects instantiate classes. The main advantage of OOP is that it makes code easier to understand, maintain and reuse. Basic Concepts of OOP The main concepts of OOP include classes, objects, properties and methods. A class is the blueprint of an object, which defines its properties and behavior. An object is an instance of a class and has all the properties and behaviors of the class. Properties are characteristics of an object that can store data. Methods are functions of an object that can operate on the object's data. Advantages of OOP The main advantages of OOP include: Reusability: OOP can make the code more

How do C++ functions differ from object-oriented programming? How do C++ functions differ from object-oriented programming? Apr 11, 2024 pm 09:12 PM

Functional and Object-Oriented Programming (OOP) provide different programming mechanisms in C++: Function: independent block of code, focused on performing a specific task, containing no data. OOP: Based on objects, classes and inheritance, data and behavior are encapsulated in objects. In actual cases, the function method for calculating the area of ​​a square is simple and direct, while the OOP method encapsulates data and behavior and is more suitable for managing object interaction. Choosing the appropriate approach depends on the scenario: functions are good for independent tasks, OOP is good for managing complex object interactions.

See all articles