
现在我有一个短链: https://sourl.cn/6wKy5d ,它指向 baidu, 然后我需要前端去调用这个地址,获取它重定向的地址,这种前端有可能实现吗
1 opengps 2023-01-09 10:47:23 +08:00 用隐藏的 ifream 去访问短连接,过一会在检查下网址变化 |
2 296727 2023-01-09 11:10:01 +08:00 一个 xhr 请求之后就可以回去 res 了 |
4 zficode OP 现在我的想法是: ``` let img = document.createElement('img') img.src = 'https://sourl.cn/rC6BuB' ``` 我想拿到这个 src 对响应标头 |
5 296727 2023-01-09 13:38:33 +08:00 自己再写一个服务转发 |
6 iPhone11 2023-01-09 15:17:09 +08:00 via iPhone // 使用 XMLHttpRequest var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://sourl.cn/6wKy5d', true); xhr.Onreadystatechange= function() { if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { // 获取重定向地址 var respOnseURL= xhr.responseURL; console.log(responseURL); } } xhr.send(); // 使用 fetch fetch('https://sourl.cn/6wKy5d', { redirect: 'follow' }).then(res => { // 获取重定向地址 var respOnseURL= res.url; console.log(responseURL); }); 哪里不明白,我再补充 |