XMLHttpRequest:responseURL 屬性
注意:此功能在 Web Workers 中可用,但 Service Workers 除外。
只讀的 XMLHttpRequest.responseURL 屬性返回響應的序列化 URL,如果 URL 為 null,則返回空字串。如果返回 URL,則 URL 中存在的任何 URL 片段都將被剝離。responseURL 的值將是經過任何重定向後獲得的最終 URL。
示例
js
const xhr = new XMLHttpRequest();
xhr.open("GET", "http://example.com/test", true);
xhr.onload = () => {
console.log(xhr.responseURL); // http://example.com/test
};
xhr.send(null);
規範
| 規範 |
|---|
| XMLHttpRequest # the-responseurl-attribute |
瀏覽器相容性
載入中…