EventSource: thuộc tính withCredentials

Baseline Widely available

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

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc withCredentials của giao diện EventSource trả về một giá trị boolean cho biết đối tượng EventSource có được khởi tạo với bộ thông tin xác thực CORS hay không.

Giá trị

Một giá trị boolean cho biết đối tượng EventSource có được khởi tạo với bộ thông tin xác thực CORS (true) hay không (false, mặc định).

Ví dụ

js
const evtSource = new EventSource("sse.php");
console.log(evtSource.withCredentials);

Note: Bạn có thể tìm thấy một ví dụ đầy đủ trên GitHub, xem Simple SSE demo using PHP.

Thông số kỹ thuật

Specification
HTML
# dom-eventsource-withcredentials-dev

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

Xem thêm