WorkerLocation: thuộc tính host

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Note: This feature is only available in Web Workers.

Thuộc tính host của đối tượng WorkerLocation trả về phần host trong vị trí của worker.

Giá trị

Một chuỗi.

Ví dụ

js
// Trong một Web worker, trên trang http://localhost:8080/
const result = location.host; // Trả về 'localhost:8080'

Thông số kỹ thuật

Thông số kỹ thuật
HTML
# dom-workerlocation-host

Tương thích trình duyệt

Xem thêm